Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-06-17 20:15:15 +0300
committerJunio C Hamano <gitster@pobox.com>2019-06-17 20:15:15 +0300
commit86d87307c1c490282749e278380b9a258de0b46c (patch)
treeeeac81ad5d3611520950f7ac59229c2033e23fcb
parent63b6b4b7e107d5b40620d0b3dc3efff0284dfb7b (diff)
parent533e088250cf4e8aad3143586850d7a89ed30571 (diff)
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
-rw-r--r--ls-refs.c3
-rwxr-xr-xt/t5509-fetch-push-namespaces.sh28
-rw-r--r--upload-pack.c4
3 files changed, 32 insertions, 3 deletions
diff --git a/ls-refs.c b/ls-refs.c
index 0a7dbc6442..818aef70a0 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -57,7 +57,8 @@ static int send_ref(const char *refname, const struct object_id *oid,
if (!symref_target)
die("'%s' is a symref but it is not?", refname);
- strbuf_addf(&refline, " symref-target:%s", symref_target);
+ strbuf_addf(&refline, " symref-target:%s",
+ strip_namespace(symref_target));
}
if (data->peel) {
diff --git a/t/t5509-fetch-push-namespaces.sh b/t/t5509-fetch-push-namespaces.sh
index c88df78c0b..75cbfcc392 100755
--- a/t/t5509-fetch-push-namespaces.sh
+++ b/t/t5509-fetch-push-namespaces.sh
@@ -124,4 +124,32 @@ test_expect_success 'try to update a hidden full ref' '
test_must_fail git -C original push pushee-namespaced master
'
+test_expect_success 'set up ambiguous HEAD' '
+ git init ambiguous &&
+ (
+ cd ambiguous &&
+ git commit --allow-empty -m foo &&
+ git update-ref refs/namespaces/ns/refs/heads/one HEAD &&
+ git update-ref refs/namespaces/ns/refs/heads/two HEAD &&
+ git symbolic-ref refs/namespaces/ns/HEAD \
+ refs/namespaces/ns/refs/heads/two
+ )
+'
+
+test_expect_success 'clone chooses correct HEAD (v0)' '
+ GIT_NAMESPACE=ns git -c protocol.version=0 \
+ clone ambiguous ambiguous-v0 &&
+ echo refs/heads/two >expect &&
+ git -C ambiguous-v0 symbolic-ref HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'clone chooses correct HEAD (v2)' '
+ GIT_NAMESPACE=ns git -c protocol.version=2 \
+ clone ambiguous ambiguous-v2 &&
+ echo refs/heads/two >expect &&
+ git -C ambiguous-v2 symbolic-ref HEAD >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/upload-pack.c b/upload-pack.c
index 24298913c0..4d2129e7fc 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1037,8 +1037,8 @@ static int find_symref(const char *refname, const struct object_id *oid,
symref_target = resolve_ref_unsafe(refname, 0, NULL, &flag);
if (!symref_target || (flag & REF_ISSYMREF) == 0)
die("'%s' is a symref but it is not?", refname);
- item = string_list_append(cb_data, refname);
- item->util = xstrdup(symref_target);
+ item = string_list_append(cb_data, strip_namespace(refname));
+ item->util = xstrdup(strip_namespace(symref_target));
return 0;
}