summaryrefslogtreecommitdiff
path: root/transport-helper.c
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2014-04-20 13:59:26 -0500
committerJunio C Hamano <gitster@pobox.com>2014-04-21 11:47:33 -0700
commit9193f742350d1b97e32b0687d1577dc2b2a0d713 (patch)
treead7f147dc27861e5d0d56ff3c3047f1976d46fd5 /transport-helper.c
parentd98c81538015630603fd20f6e08e960555a38c52 (diff)
downloadgit-9193f742350d1b97e32b0687d1577dc2b2a0d713.tar.gz
transport-helper: add support to push symbolic refs
For example 'HEAD'. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport-helper.c')
-rw-r--r--transport-helper.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/transport-helper.c b/transport-helper.c
index 3f45c478fa..f74eb57046 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);