summaryrefslogtreecommitdiff
path: root/ls-refs.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2019-01-17 23:33:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-18 20:48:41 (GMT)
commite2f41a0a5aaa0116c9f1463fd779ce832eb773cc (patch)
tree68ff94301aa8b783046eb25a867c8b1df2b9e147 /ls-refs.c
parent77556354bb7ac50450e3b28999e3576969869068 (diff)
downloadgit-e2f41a0a5aaa0116c9f1463fd779ce832eb773cc.zip
git-e2f41a0a5aaa0116c9f1463fd779ce832eb773cc.tar.gz
git-e2f41a0a5aaa0116c9f1463fd779ce832eb773cc.tar.bz2
ls-refs: filter refs using namespace-stripped name
If a user fetches refs/heads/master from a repo with namespace "ns", the remote is expected to (1) not send the real refs/heads/master, and (2) send refs/namespaces/ns/refs/heads/master with the name refs/heads/master. (1) indeed happens now, but not (2) - Git only sends refs that have the user-given prefix, but it checks them against the full name of the ref (the one starting with refs/namespaces), and not the namespace-stripped one. This is demonstrated by the patch in the test. Currently, it results in "fatal: couldn't find remote ref refs/heads/master" despite both unnamespaced and namespaced master being present. With the code change, it produces the expected result. Check the ref prefixes against the namespace-stripped name. This bug was discovered through applying patches [1] that override protocol.version to 2 in repositories when running tests, allowing us to notice differences in behavior across different protocol versions. [1] https://public-inbox.org/git/cover.1547677183.git.jonathantanmy@google.com/ Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ls-refs.c')
-rw-r--r--ls-refs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ls-refs.c b/ls-refs.c
index a06f12e..7782bb0 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -40,7 +40,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
const char *refname_nons = strip_namespace(refname);
struct strbuf refline = STRBUF_INIT;
- if (!ref_match(&data->prefixes, refname))
+ if (!ref_match(&data->prefixes, refname_nons))
return 0;
strbuf_addf(&refline, "%s %s", oid_to_hex(oid), refname_nons);