fetch-pack: eliminate spurious error messages

It used to be that if "--all", "--depth", and also explicit references were sought, then the explicit references were not handled correctly in filter_refs() because the "--all --depth" code took precedence over the explicit reference handling, and the explicit references were never noted as having been found. So check for explicitly sought references before proceeding to the "--all --depth" logic. This fixes two test cases in t5500. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Sep 9, 2012 at 08:19 UTC 5f0fc64513c8cb638e0d6010005d8e86c9dbca3a
2 files changed +7 -7
builtin/fetch-pack.c
+5 -5
@@ -549,9 +549,6 @@ static void filter_refs(struct ref **refs, struct string_list *sought)
549 if (!memcmp(ref->name, "refs/", 5) &&
550 check_refname_format(ref->name + 5, 0))
551 ; /* trash */
552 - else if (args.fetch_all &&
553 - (!args.depth || prefixcmp(ref->name, "refs/tags/")))
554 - keep = 1;
552 else {
553 while (sought_pos < sought->nr) {
554 int cmp = strcmp(ref->name, sought->items[sought_pos].string);
@@ -567,6 +564,10 @@ static void filter_refs(struct ref **refs, struct string_list *sought)
564 }
565 }
566
567 + if (! keep && args.fetch_all &&
568 + (!args.depth || prefixcmp(ref->name, "refs/tags/")))
569 + keep = 1;
570 +
571 if (keep) {
572 *newtail = ref;
573 ref->next = NULL;
@@ -576,8 +577,7 @@ static void filter_refs(struct ref **refs, struct string_list *sought)
577 }
578 }
579
579 - if (!args.fetch_all)
580 - filter_string_list(sought, 0, non_matching_ref, NULL);
580 + filter_string_list(sought, 0, non_matching_ref, NULL);
581 *refs = newlist;
582 }
583
t/t5500-fetch-pack.sh
+2 -2
@@ -427,14 +427,14 @@ test_expect_success 'test missing ref before existing' '
427 test_cmp expect-error error-me
428 '
429
430 -test_expect_failure 'test --all, --depth, and explicit head' '
430 +test_expect_success 'test --all, --depth, and explicit head' '
431 (
432 cd client &&
433 git fetch-pack --no-progress --all --depth=1 .. refs/heads/A
434 ) >out-adh 2>error-adh
435 '
436
437 -test_expect_failure 'test --all, --depth, and explicit tag' '
437 +test_expect_success 'test --all, --depth, and explicit tag' '
438 git tag OLDTAG refs/heads/B~5 &&
439 (
440 cd client &&