Skip to content

Commit 86d8730

Browse files
committed
Merge branch 'jk/HEAD-symref-in-xfer-namespaces'
The server side support for "git fetch" used to show incorrect value for the HEAD symbolic ref when the namespace feature is in use, which has been corrected. * jk/HEAD-symref-in-xfer-namespaces: upload-pack: strip namespace from symref data
2 parents 63b6b4b + 533e088 commit 86d8730

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

ls-refs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ static int send_ref(const char *refname, const struct object_id *oid,
5757
if (!symref_target)
5858
die("'%s' is a symref but it is not?", refname);
5959

60-
strbuf_addf(&refline, " symref-target:%s", symref_target);
60+
strbuf_addf(&refline, " symref-target:%s",
61+
strip_namespace(symref_target));
6162
}
6263

6364
if (data->peel) {

t/t5509-fetch-push-namespaces.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,32 @@ test_expect_success 'try to update a hidden full ref' '
124124
test_must_fail git -C original push pushee-namespaced master
125125
'
126126

127+
test_expect_success 'set up ambiguous HEAD' '
128+
git init ambiguous &&
129+
(
130+
cd ambiguous &&
131+
git commit --allow-empty -m foo &&
132+
git update-ref refs/namespaces/ns/refs/heads/one HEAD &&
133+
git update-ref refs/namespaces/ns/refs/heads/two HEAD &&
134+
git symbolic-ref refs/namespaces/ns/HEAD \
135+
refs/namespaces/ns/refs/heads/two
136+
)
137+
'
138+
139+
test_expect_success 'clone chooses correct HEAD (v0)' '
140+
GIT_NAMESPACE=ns git -c protocol.version=0 \
141+
clone ambiguous ambiguous-v0 &&
142+
echo refs/heads/two >expect &&
143+
git -C ambiguous-v0 symbolic-ref HEAD >actual &&
144+
test_cmp expect actual
145+
'
146+
147+
test_expect_success 'clone chooses correct HEAD (v2)' '
148+
GIT_NAMESPACE=ns git -c protocol.version=2 \
149+
clone ambiguous ambiguous-v2 &&
150+
echo refs/heads/two >expect &&
151+
git -C ambiguous-v2 symbolic-ref HEAD >actual &&
152+
test_cmp expect actual
153+
'
154+
127155
test_done

upload-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,8 @@ static int find_symref(const char *refname, const struct object_id *oid,
10371037
symref_target = resolve_ref_unsafe(refname, 0, NULL, &flag);
10381038
if (!symref_target || (flag & REF_ISSYMREF) == 0)
10391039
die("'%s' is a symref but it is not?", refname);
1040-
item = string_list_append(cb_data, refname);
1041-
item->util = xstrdup(symref_target);
1040+
item = string_list_append(cb_data, strip_namespace(refname));
1041+
item->util = xstrdup(strip_namespace(symref_target));
10421042
return 0;
10431043
}
10441044

0 commit comments

Comments
 (0)