Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Martin Veilleux <>
To: <>
Subject: [BUG] fetch error when arbitrary branch changes a submodule url
Date: Wed, 8 May 2024 19:45:03 -0400	[thread overview]
Message-ID: <> (raw)

[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]

issue: fetch will give a fatal error once when a new arbitrary branch on 
the remote contains a submodule url change with updated sha

This was an issue I originally opened on git-for-windows a while back. 

But it's actually reproducible on Linux

Seems to be a regression since I could not repro on version 1.9

Issue still present on version

Local repro steps (complete test script attached)
- create repo A with a commit on master
- create repo B with a commit on master
- create repo X and add a submodule S1 pointing to A, commit to master.
- clone repo X with submodules to repo Z
- in repo X, create branch X1 from master. Change submodule S1 url to 
repo B and commit on X1.
- in repo Z, fetch and notice the fatal error "upload-pack: not our ref SHA"

 From there, you can then quickly repro the error like so:
- in repo Z , delete branch origin/X1 and then fetch again.

Current workaround is to set submodule.recurse to false



[-- Attachment #2: --]
[-- Type: text/plain, Size: 2747 bytes --]


    echo "FATAL program error"
    exit 1

    echo "git $*"
    git $*

    echo "git $*"
    git $* || die

    local name=$1
    [[ -n "$name" ]] || die
    mkdir $name || die
    pushd $name >/dev/null
    gitNoFail init
    echo line1>readme.txt
    gitNoFail add readme.txt
    gitNoFail commit -m first
    popd >/dev/null
    echo "created git repo '$name'"

    echo "=============================================================="
    if [[ -n "$1" ]]; then
        echo "$1"
        echo "=============================================================="

    if [[ -n "$GIT_PATH" ]]; then
        [[ -e "$GIT_PATH/git" ]] || die
        echo "user provided custom git in ${GIT_PATH}"
        export PATH="${GIT_PATH}:${PATH}"
        gitNoFail --version

    local root=$(pwd)
    rm -rf child{1,2} user1 server1
    local gitArgs="-c protocol.file.allow=always"
    #create submodule repos
    printHeader "create submodule repo 1"
    createRepo child1
    printHeader "create submodule repo 2"
    createRepo child2
    #workaround for identical initial SHA (is this a bug?)
    pushd child2 >/dev/null
    touch foobar
    gitNoFail add foobar
    gitNoFail commit -m second
    popd >/dev/null

    #create a repo intended as the server repo that all users clone from
    printHeader "setup server repo"
    createRepo server1
    #add submodule
    pushd server1 >/dev/null
    gitNoFail ${gitArgs} submodule add -b master "${root}/child1" sub1
    gitNoFail commit -m added_submodule
    popd >/dev/null
    #a user clones from server
    printHeader "setup user repo"
    gitNoFail ${gitArgs} clone --recurse-submodules server1 user1

    #change a submodule url in an arbitrary branch. This branch would have been pushed to the server by another user.
    printHeader "switch submodule url"
    pushd server1 >/dev/null
    gitNoFail checkout -b exper
    gitNoFail config --file=.gitmodules submodule.sub1.url "${root}/child2"
    gitNoFail ${gitArgs} submodule sync -- sub1
    gitNoFail ${gitArgs} submodule update --remote -- sub1
    gitNoFail add --all
    gitNoFail commit -m switch_submodule_url
    popd >/dev/null

    #now user will update
    pushd user1 >/dev/null
    printHeader "user updates"
    #this will give an error, but shouldn't
    gitTry fetch

    #test again
    printHeader "try again"
    gitNoFail branch -r -D origin/exper
    gitTry fetch

    #test workaround
    printHeader "workaround"
    gitNoFail branch -r -D origin/exper
    gitNoFail config submodule.recurse false
    gitNoFail fetch

    popd >/dev/null

main $@

                 reply	other threads:[~2024-05-08 23:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).