Skip to content

Commit 9c96ab9

Browse files
committed
Merge branch 'jt/namespaced-ls-refs-fix'
Fix namespace support in protocol v2. * jt/namespaced-ls-refs-fix: ls-refs: filter refs using namespace-stripped name
2 parents e5eac57 + e2f41a0 commit 9c96ab9

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ls-refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
4444
if (ref_is_hidden(refname_nons, refname))
4545
return 0;
4646

47-
if (!ref_match(&data->prefixes, refname))
47+
if (!ref_match(&data->prefixes, refname_nons))
4848
return 0;
4949

5050
strbuf_addf(&refline, "%s %s", oid_to_hex(oid), refname_nons);

t/t5702-protocol-v2.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,27 @@ test_expect_success 'fetch with http:// using protocol v2' '
561561
grep "git< version 2" log
562562
'
563563

564+
test_expect_success 'fetch from namespaced repo respects namespaces' '
565+
test_when_finished "rm -f log" &&
566+
567+
git init "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" &&
568+
test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" one &&
569+
test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" two &&
570+
git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" \
571+
update-ref refs/namespaces/ns/refs/heads/master one &&
572+
573+
GIT_TRACE_PACKET="$(pwd)/log" git -C http_child -c protocol.version=2 \
574+
fetch "$HTTPD_URL/smart_namespace/nsrepo" \
575+
refs/heads/master:refs/heads/theirs &&
576+
577+
# Server responded using protocol v2
578+
grep "fetch< version 2" log &&
579+
580+
git -C "$HTTPD_DOCUMENT_ROOT_PATH/nsrepo" rev-parse one >expect &&
581+
git -C http_child rev-parse theirs >actual &&
582+
test_cmp expect actual
583+
'
584+
564585
test_expect_success 'push with http:// and a config of v2 does not request v2' '
565586
test_when_finished "rm -f log" &&
566587
# Till v2 for push is designed, make sure that if a client has

0 commit comments

Comments
 (0)