For example 'HEAD'.

Signed-off-by: Felipe Contreras <felipe.contre...@gmail.com>
---
 t/t5801-remote-helpers.sh |  8 ++++++++
 transport-helper.c        | 11 ++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 52b3c99..8288669 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -94,6 +94,14 @@ test_expect_success 'push new branch with old:new refspec' '
        compare_refs local HEAD server refs/heads/new-refspec
 '
 
+test_expect_success 'push new branch with HEAD:new refspec' '
+       (cd local &&
+        git checkout new-name
+        git push origin HEAD:new-refspec-2
+       ) &&
+       compare_refs local HEAD server refs/heads/new-refspec-2
+'
+
 test_expect_success 'forced push' '
        (cd local &&
        git checkout -b force-test &&
diff --git a/transport-helper.c b/transport-helper.c
index 3f45c47..f74eb57 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -896,7 +896,16 @@ static int push_refs_with_export(struct transport 
*transport,
                if (ref->peer_ref) {
                        if (strcmp(ref->name, ref->peer_ref->name)) {
                                struct strbuf buf = STRBUF_INIT;
-                               strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, 
ref->name);
+                               const char *name;
+                               int flag;
+
+                               /* Follow symbolic refs (mainly for HEAD). */
+                               name = resolve_ref_unsafe(ref->peer_ref->name, 
sha1, 1, &flag);
+                               if (!name || !(flag & REF_ISSYMREF))
+                                       name = ref->peer_ref->name;
+
+                               strbuf_addf(&buf, "%s:%s", name, ref->name);
+
                                string_list_append(&revlist_args, "--refspec");
                                string_list_append(&revlist_args, buf.buf);
                                strbuf_release(&buf);
-- 
1.9.1+fc3.9.gc73078e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to