fetch-pack: eliminate spurious error messages
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 9 Sep 2012 06:19:49 +0000 (08:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Sep 2012 18:46:32 +0000 (11:46 -0700)
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>
builtin/fetch-pack.c
t/t5500-fetch-pack.sh

index 42078e5cd5ca8b08f8f4b4d512950a8403537004..e6443986b81050b01ebd7c57a7afd7abb5c65a45 100644 (file)
@@ -549,9 +549,6 @@ static void filter_refs(struct ref **refs, struct string_list *sought)
                if (!memcmp(ref->name, "refs/", 5) &&
                    check_refname_format(ref->name + 5, 0))
                        ; /* trash */
-               else if (args.fetch_all &&
-                        (!args.depth || prefixcmp(ref->name, "refs/tags/")))
-                       keep = 1;
                else {
                        while (sought_pos < sought->nr) {
                                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)
                        }
                }
 
+               if (! keep && args.fetch_all &&
+                   (!args.depth || prefixcmp(ref->name, "refs/tags/")))
+                       keep = 1;
+
                if (keep) {
                        *newtail = ref;
                        ref->next = NULL;
@@ -576,8 +577,7 @@ static void filter_refs(struct ref **refs, struct string_list *sought)
                }
        }
 
-       if (!args.fetch_all)
-               filter_string_list(sought, 0, non_matching_ref, NULL);
+       filter_string_list(sought, 0, non_matching_ref, NULL);
        *refs = newlist;
 }
 
index 894d945bdd6f0e6067c57f7c4315f759b34b0ef3..6322e8ade8436dc4e66b9874638e7ca6b7d222b3 100755 (executable)
@@ -427,14 +427,14 @@ test_expect_success 'test missing ref before existing' '
        test_cmp expect-error error-me
 '
 
-test_expect_failure 'test --all, --depth, and explicit head' '
+test_expect_success 'test --all, --depth, and explicit head' '
        (
                cd client &&
                git fetch-pack --no-progress --all --depth=1 .. refs/heads/A
        ) >out-adh 2>error-adh
 '
 
-test_expect_failure 'test --all, --depth, and explicit tag' '
+test_expect_success 'test --all, --depth, and explicit tag' '
        git tag OLDTAG refs/heads/B~5 &&
        (
                cd client &&