From: John Keeping <hidden> Date: 2016-06-15 22:57:27
Since commit f269048 (fetch: opportunistically update tracking refs,
2013-05-11) we update tracking refs opportunistically when fetching
remote branches. However, if a refspec is given on the command line
that does not include a configured (non-pattern) refspec a fatal error
occurs.
Fix this by setting the "missing_ok" flag when calling get_fetch_map.
Signed-off-by: John Keeping <redacted>
---
builtin/fetch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Jeff King <hidden> Date: 2016-06-15 22:57:27
On Mon, May 27, 2013 at 12:40:25PM +0100, John Keeping wrote:
Since commit f269048 (fetch: opportunistically update tracking refs,
2013-05-11) we update tracking refs opportunistically when fetching
remote branches. However, if a refspec is given on the command line
that does not include a configured (non-pattern) refspec a fatal error
occurs.
I'm not sure I understand what the last sentence means. I tried to add a
test like:
@@ -422,6 +422,16 @@ test_expect_success 'configured fetch updates tracking' ')'+test_expect_success'non-configured ref does not confuse tracking update''+cd"$D"&&+gitupdate-refrefs/odd/locationHEAD&&+(+cdthree&&+gitfetchoriginrefs/odd/location&&+gitrev-parse--verifyFETCH_HEAD+)+'+ test_expect_success'pushing nonexistent branch by mistake should not segv''cd"$D"&&
but it does not fail with the existing code. Can you give an example
that fails?
-Peff
From: John Keeping <hidden> Date: 2016-06-15 22:57:27
On Mon, May 27, 2013 at 11:42:52AM -0400, Jeff King wrote:
quoted hunk
On Mon, May 27, 2013 at 12:40:25PM +0100, John Keeping wrote:
quoted
Since commit f269048 (fetch: opportunistically update tracking refs,
2013-05-11) we update tracking refs opportunistically when fetching
remote branches. However, if a refspec is given on the command line
that does not include a configured (non-pattern) refspec a fatal error
occurs.
I'm not sure I understand what the last sentence means. I tried to add a
test like:
@@ -422,6 +422,16 @@ test_expect_success 'configured fetch updates tracking' ')'+test_expect_success'non-configured ref does not confuse tracking update''+cd"$D"&&+gitupdate-refrefs/odd/locationHEAD&&+(+cdthree&&+gitfetchoriginrefs/odd/location&&+gitrev-parse--verifyFETCH_HEAD+)+'+ test_expect_success'pushing nonexistent branch by mistake should not segv''cd"$D"&&
but it does not fail with the existing code. Can you give an example
that fails?
I have this in my .git/config for git.git:
[remote "origin"]
url = git://github.com/gitster/git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/notes/amlog:refs/notes/amlog
Then doing "git fetch origin master" fails because:
fatal: Couldn't find remote ref refs/notes/amlog
The following test fails for me (and passes with my patch) - note that
in "two", remote.one.fetch is configured as
"refs/heads/master:refs/heads/one".
-- >8 --
@@ -422,6 +422,19 @@ test_expect_success 'configured fetch updates tracking' ')'+test_expect_success'configured ref does not confuse tracking''++cd"$D"&&+(+cdone&&+gitbranch-fside+)&&+(+cdtwo&&+gitfetchoneside+)+'+ test_expect_success'pushing nonexistent branch by mistake should not segv''cd"$D"&&
From: Jeff King <hidden> Date: 2016-06-15 22:57:27
On Mon, May 27, 2013 at 05:01:29PM +0100, John Keeping wrote:
quoted
I'm not sure I understand what the last sentence means. I tried to add a
test like:
[...]
quoted
but it does not fail with the existing code. Can you give an example
that fails?
I have this in my .git/config for git.git:
[remote "origin"]
url = git://github.com/gitster/git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/notes/amlog:refs/notes/amlog
Ah, I see. It is not "the refspec on the command-line does not match a
configured refspec", but rather "there exists a configured non-pattern
refspec that does not match what was on the command-line (even if what
was on the command-line did match another refspec)".
So your fix makes perfect sense. Do you mind squashing in this test
below? I think it is a little less subtle than what you posted, as it
sets up the situation explicitly in the test. It also checks that the
refs we _did_ match still get updated ("master" in this case).
@@ -422,6 +422,22 @@ test_expect_success 'configured fetch updates tracking' ')'+test_expect_success'non-matching refspecs do not confuse tracking update''+cd"$D"&&+gitupdate-refrefs/odd/locationHEAD&&+(+cdthree&&+gitupdate-refrefs/remotes/origin/masterbase-origin-master&&+gitconfig--addremote.origin.fetch\+refs/odd/location:refs/remotes/origin/odd&&+o=$(gitrev-parse--verifyrefs/remotes/origin/master)&&+gitfetchoriginmaster&&+n=$(gitrev-parse--verifyrefs/remotes/origin/master)&&+test"$o"!="$n"&&+test_must_failgitrev-parse--verifyrefs/remotes/origin/odd+)+'+ test_expect_success'pushing nonexistent branch by mistake should not segv''cd"$D"&&
Thanks for the fix.
Acked-by: Jeff King <redacted>
-Peff
From: John Keeping <hidden> Date: 2016-06-15 22:57:27
Since commit f269048 (fetch: opportunistically update tracking refs,
2013-05-11) we update tracking refs opportunistically when fetching
remote branches. However, if there is a configured non-pattern refspec
that does not match any of the refspecs given on the command line then a
fatal error occurs.
Fix this by setting the "missing_ok" flag when calling get_fetch_map.
Test-added-by: Jeff King [off-list ref]
Signed-off-by: John Keeping <redacted>
Acked-by: Jeff King <redacted>
---
On Mon, May 27, 2013 at 12:19:34PM -0400, Jeff King wrote:
On Mon, May 27, 2013 at 05:01:29PM +0100, John Keeping wrote:
quoted
quoted
I'm not sure I understand what the last sentence means. I tried to add a
test like:
[...]
quoted
but it does not fail with the existing code. Can you give an example
that fails?
I have this in my .git/config for git.git:
[remote "origin"]
url = git://github.com/gitster/git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/notes/amlog:refs/notes/amlog
Ah, I see. It is not "the refspec on the command-line does not match a
configured refspec", but rather "there exists a configured non-pattern
refspec that does not match what was on the command-line (even if what
was on the command-line did match another refspec)".
Exactly. I've changed the commit message to (hopefully) make this
clearer.
So your fix makes perfect sense. Do you mind squashing in this test
below? I think it is a little less subtle than what you posted, as it
sets up the situation explicitly in the test. It also checks that the
refs we _did_ match still get updated ("master" in this case).
@@ -422,6 +422,22 @@ test_expect_success 'configured fetch updates tracking' ')'+test_expect_success'non-matching refspecs do not confuse tracking update''+cd"$D"&&+gitupdate-refrefs/odd/locationHEAD&&+(+cdthree&&+gitupdate-refrefs/remotes/origin/masterbase-origin-master&&+gitconfig--addremote.origin.fetch\+refs/odd/location:refs/remotes/origin/odd&&+o=$(gitrev-parse--verifyrefs/remotes/origin/master)&&+gitfetchoriginmaster&&+n=$(gitrev-parse--verifyrefs/remotes/origin/master)&&+test"$o"!="$n"&&+test_must_failgitrev-parse--verifyrefs/remotes/origin/odd+)+'+ test_expect_success'pushing nonexistent branch by mistake should not segv''cd"$D"&&
From: Jeff King <hidden> Date: 2016-06-15 22:57:27
On Mon, May 27, 2013 at 05:33:09PM +0100, John Keeping wrote:
quoted
Ah, I see. It is not "the refspec on the command-line does not match a
configured refspec", but rather "there exists a configured non-pattern
refspec that does not match what was on the command-line (even if what
was on the command-line did match another refspec)".
Exactly. I've changed the commit message to (hopefully) make this
clearer.