Skip to content

Commit 5f0fc64

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b285668 commit 5f0fc64

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

builtin/fetch-pack.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,6 @@ static void filter_refs(struct ref **refs, struct string_list *sought)
549549
if (!memcmp(ref->name, "refs/", 5) &&
550550
check_refname_format(ref->name + 5, 0))
551551
; /* trash */
552-
else if (args.fetch_all &&
553-
(!args.depth || prefixcmp(ref->name, "refs/tags/")))
554-
keep = 1;
555552
else {
556553
while (sought_pos < sought->nr) {
557554
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)
567564
}
568565
}
569566

567+
if (! keep && args.fetch_all &&
568+
(!args.depth || prefixcmp(ref->name, "refs/tags/")))
569+
keep = 1;
570+
570571
if (keep) {
571572
*newtail = ref;
572573
ref->next = NULL;
@@ -576,8 +577,7 @@ static void filter_refs(struct ref **refs, struct string_list *sought)
576577
}
577578
}
578579

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);
581581
*refs = newlist;
582582
}
583583

t/t5500-fetch-pack.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,14 @@ test_expect_success 'test missing ref before existing' '
427427
test_cmp expect-error error-me
428428
'
429429

430-
test_expect_failure 'test --all, --depth, and explicit head' '
430+
test_expect_success 'test --all, --depth, and explicit head' '
431431
(
432432
cd client &&
433433
git fetch-pack --no-progress --all --depth=1 .. refs/heads/A
434434
) >out-adh 2>error-adh
435435
'
436436

437-
test_expect_failure 'test --all, --depth, and explicit tag' '
437+
test_expect_success 'test --all, --depth, and explicit tag' '
438438
git tag OLDTAG refs/heads/B~5 &&
439439
(
440440
cd client &&

0 commit comments

Comments
 (0)