-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch will give a fatal error once when a new arbitrary branch on the remote contains a submodule url change with updated sha #3404
Comments
I simplified the reproducer a bit, to not require Bash: #!/bin/sh
createRepo()
{
git init "$1" &&
git -C "$1" commit --allow-empty -m first
}
rm -rf child1 child2 user1 user2 &&
#create submodules
createRepo child1 &&
createRepo child2 &&
#workaround for identical initial SHA
git -C child2 commit --allow-empty -m second &&
#create main repo
createRepo user1 &&
#add submodule
git -C user1 submodule add -b master "../child1" sub1 &&
git -C user1 commit -m 'added submodule' &&
#another user clones repo
git clone --recurse-submodules user1 user2 &&
#switch submodule url in main repo in arbitrary branch
git -C user1 checkout -b exper &&
git config --file=user1/.gitmodules submodule.sub1.url "../child2" &&
git -C user1 submodule sync -- sub1 &&
git -C user1 submodule update --remote -- sub1 &&
git -C user1 commit -m 'switch submodule url' sub1 &&
#now user will update
#this will give an error, but shouldn't
git -C user2 fetch &&
#test again
git -C user2 branch -r -D origin/exper &&
git -C user2 fetch &&
#test workaround
git -C user2 branch -r -D origin/exper &&
git -C user2 config submodule.recurse false &&
git -C user2 fetch And I can confirm that this fails in the indicated spot. I can also confirm that this fails in just the same way on Linux, and therefore this is not a Windows-specific bug. So I looked at the Git mailing list, trying to figure out whether this has been reported already. I find a couple of hits when looking for "not our ref": https://lore.kernel.org/git/?q=%22not+our+ref%22 The most likely candidate is https://lore.kernel.org/git/5a70d535-47b0-a4ea-b4e4-572a1bcfe997@gmail.com/, but it seems that the reported use case changes the URL in the same branch. And it seems the reporter was okay with the resolution. However, I think that the issue here is that the URL was changed on a separate branch, and that Git incorrectly thought that it had the commits in said branch available. Therefore, this looks like an upstream bug to me (my hunch is that the ref advertisement has been made a bit overzealous recently). Hence I would recommend to take it to the Git mailing list (send plain-text messages, HTML messages are dropped silently). Your best chance will be to provide the reproducer in the form of a patch to Git's own test suite. I spent a bit more time on this than I had planned, but I think this will get you somewhere: diff --git a/t/t3050-subprojects-fetch.sh b/t/t3050-subprojects-fetch.sh
index f1f09abdd9b..5739687a842 100755
--- a/t/t3050-subprojects-fetch.sh
+++ b/t/t3050-subprojects-fetch.sh
@@ -49,4 +49,23 @@ test_expect_success fetch '
test_cmp expected actual
'
+test_expect_success 'with unfetched commit from new URL in other branch' '
+ test_create_repo super &&
+ git -C super submodule add ../sub &&
+ git -C super commit -m "add sub" &&
+
+ git clone --recurse-submodules super cloned-before-move &&
+
+ git clone sub new-sub &&
+ test_commit -C new-sub after-move &&
+
+ git -C super switch -c change-url &&
+ git -C super config -f .gitmodules submodule.sub.url "$PWD/new-sub" &&
+ git -C super submodule sync -- sub &&
+ git -C super submodule update --remote -- sub &&
+ git -C super commit -m "changed submodule URL" .gitmodules sub &&
+
+ git -C cloned-before-move fetch --recurse-submodules
+'
+
test_done |
The issue as I understand it:
createRepo()
{
git init "$1" &&
git -C "$1" commit --allow-empty -m first
}
rm -rf child1 child2 user1 user2 &&
#create submodules
createRepo child1 &&
createRepo child2 &&
#workaround for identical initial SHA
git -C child2 commit --allow-empty -m second &&
#create main repo
createRepo user1 &&
#add submodule
git -C user1 submodule add -b master "../child1" sub1 &&
git -C user1 commit -m 'added submodule' &&
#another user clones repo
git clone --recurse-submodules user1 user2 &&
#switch submodule url in main repo in arbitrary branch
git -C user1 checkout -b exper &&
git config --file=user1/.gitmodules submodule.sub1.url "../child2" &&
git -C user1 submodule sync -- sub1 &&
git -C user1 submodule update --remote -- sub1 &&
git -C user1 commit -m 'switch submodule url' sub1 .gitmodules
#now user will update
git -C user2 fetch #error
git -C user2/sub1 config remote.origin.url #child1
git -C user2 checkout origin/exper
git -C user2 submodule sync
git -C user2/sub1 config remote.origin.url #child2
git -C user2 fetch --recurse-submodules #ok |
@dscho Thanks for that. Guess I'll open an issue with Git as you suggest. |
fetch will give a fatal error once when a new arbitrary branch on the remote contains a submodule url change with updated sha
Local repro steps (complete test script provided below)
From there, you can then quickly repro the error like so:
Current workaround is to set submodule.recurse to false
I could not repro on Git for Linux 1.9 (which is the one bundled in my Linux Ubuntu subsystem for Windows)
Setup
defaults?
to the issue you're seeing?
NA
Details
Bash
Minimal, Complete, and Verifiable example
this will help us understand the issue.
fetch should complete with no errors. Git for Linux 1.9 doesn't exhibit this behavior
fetch gave a fatal error like this
URL to that repository to help us with testing?
NA
The text was updated successfully, but these errors were encountered: