fetch: don't try to update unfetched tracking refs
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>
John Keeping committed
May 27, 2013 at 17:33 UTC
823c6d56a83f3eec657a94581c23c5b7682bdaf4
2 files changed
+17
-1
builtin/fetch.c
+1
-1
@@ -183,7 +183,7 @@ static struct ref *get_ref_map(struct transport *transport,
183
old_tail = tail;
184
for (i = 0; i < transport->remote->fetch_refspec_nr; i++)
185
get_fetch_map(ref_map, &transport->remote->fetch[i],
186
- &tail, 0);
186
+ &tail, 1);
187
for (rm = *old_tail; rm; rm = rm->next)
188
rm->fetch_head_status = FETCH_HEAD_IGNORE;
189
} else {
t/t5510-fetch.sh
+16
@@ -422,6 +422,22 @@ test_expect_success 'configured fetch updates tracking' '
422
)
423
'
424
425
+test_expect_success 'non-matching refspecs do not confuse tracking update' '
426
+ cd "$D" &&
427
+ git update-ref refs/odd/location HEAD &&
428
+ (
429
+ cd three &&
430
+ git update-ref refs/remotes/origin/master base-origin-master &&
431
+ git config --add remote.origin.fetch \
432
+ refs/odd/location:refs/remotes/origin/odd &&
433
+ o=$(git rev-parse --verify refs/remotes/origin/master) &&
434
+ git fetch origin master &&
435
+ n=$(git rev-parse --verify refs/remotes/origin/master) &&
436
+ test "$o" != "$n" &&
437
+ test_must_fail git rev-parse --verify refs/remotes/origin/odd
438
+ )
439
+'
440
+
441
test_expect_success 'pushing nonexistent branch by mistake should not segv' '
442
443
cd "$D" &&