Skip to content

Commit c337684

Browse files
committed
Merge branch 'jk/allow-fetch-onelevel-refname' into maint
"git clone" would fail to clone from a repository that has a ref directly under "refs/", e.g. "refs/stash", because different validation paths do different things on such a refname. Loosen the client side's validation to allow such a ref. * jk/allow-fetch-onelevel-refname: fetch-pack: do not filter out one-level refs
2 parents 21261fa + 4c22408 commit c337684

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

fetch-pack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static void filter_refs(struct fetch_pack_args *args,
507507
next = ref->next;
508508

509509
if (!memcmp(ref->name, "refs/", 5) &&
510-
check_refname_format(ref->name + 5, 0))
510+
check_refname_format(ref->name, 0))
511511
; /* trash */
512512
else {
513513
while (i < nr_sought) {

t/t5510-fetch.sh

+11
Original file line numberDiff line numberDiff line change
@@ -594,4 +594,15 @@ test_expect_success 'all boundary commits are excluded' '
594594
test_bundle_object_count .git/objects/pack/pack-${pack##pack }.pack 3
595595
'
596596

597+
test_expect_success 'fetching a one-level ref works' '
598+
test_commit extra &&
599+
git reset --hard HEAD^ &&
600+
git update-ref refs/foo extra &&
601+
git init one-level &&
602+
(
603+
cd one-level &&
604+
git fetch .. HEAD refs/foo
605+
)
606+
'
607+
597608
test_done

0 commit comments

Comments
 (0)