]> granicus.if.org Git - git/commitdiff
fetch: don't try to update unfetched tracking refs
authorJohn Keeping <john@keeping.me.uk>
Mon, 27 May 2013 16:33:09 +0000 (17:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 May 2013 15:13:14 +0000 (08:13 -0700)
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 <peff@peff.net>
Signed-off-by: John Keeping <john@keeping.me.uk>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
t/t5510-fetch.sh

index e41cc0d733793a630933b7dddb0d8f8ee4f595ed..d15a7343d8384d05784aa5739dc758262f750a25 100644 (file)
@@ -183,7 +183,7 @@ static struct ref *get_ref_map(struct transport *transport,
                old_tail = tail;
                for (i = 0; i < transport->remote->fetch_refspec_nr; i++)
                        get_fetch_map(ref_map, &transport->remote->fetch[i],
-                                     &tail, 0);
+                                     &tail, 1);
                for (rm = *old_tail; rm; rm = rm->next)
                        rm->fetch_head_status = FETCH_HEAD_IGNORE;
        } else {
index ff43e08755f79f53407abf10869aadc4567d4705..fde689166a5dcb419e0519580d628f91f1f29f83 100755 (executable)
@@ -422,6 +422,22 @@ test_expect_success 'configured fetch updates tracking' '
        )
 '
 
+test_expect_success 'non-matching refspecs do not confuse tracking update' '
+       cd "$D" &&
+       git update-ref refs/odd/location HEAD &&
+       (
+               cd three &&
+               git update-ref refs/remotes/origin/master base-origin-master &&
+               git config --add remote.origin.fetch \
+                       refs/odd/location:refs/remotes/origin/odd &&
+               o=$(git rev-parse --verify refs/remotes/origin/master) &&
+               git fetch origin master &&
+               n=$(git rev-parse --verify refs/remotes/origin/master) &&
+               test "$o" != "$n" &&
+               test_must_fail git rev-parse --verify refs/remotes/origin/odd
+       )
+'
+
 test_expect_success 'pushing nonexistent branch by mistake should not segv' '
 
        cd "$D" &&