By using fast-export's new --refspec option.

Signed-off-by: Felipe Contreras <felipe.contre...@gmail.com>
---
 t/t5801-remote-helpers.sh |  2 +-
 transport-helper.c        | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index dbb02e2..d15f794 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -92,7 +92,7 @@ test_expect_success 'push new branch by name' '
        compare_refs local HEAD server refs/heads/new-name
 '
 
-test_expect_failure 'push new branch with old:new refspec' '
+test_expect_success 'push new branch with old:new refspec' '
        (cd local &&
         git push origin new-name:new-refspec
        ) &&
diff --git a/transport-helper.c b/transport-helper.c
index 835815f..b1fdd39 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -787,7 +787,7 @@ static int push_refs_with_export(struct transport 
*transport,
        struct ref *ref;
        struct child_process *helper, exporter;
        struct helper_data *data = transport->data;
-       struct string_list revlist_args = STRING_LIST_INIT_NODUP;
+       struct string_list revlist_args = STRING_LIST_INIT_DUP;
        struct strbuf buf = STRBUF_INIT;
 
        helper = get_helper(transport);
@@ -814,14 +814,24 @@ static int push_refs_with_export(struct transport 
*transport,
                        die("remote-helpers do not support ref deletion");
                }
 
-               if (ref->peer_ref)
+               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);
+                               string_list_append(&revlist_args, "--refspec");
+                               string_list_append(&revlist_args, buf.buf);
+                               strbuf_release(&buf);
+                       }
                        string_list_append(&revlist_args, ref->peer_ref->name);
+               }
 
        }
 
        if (get_exporter(transport, &exporter, &revlist_args))
                die("Couldn't run fast-export");
 
+       string_list_clear(&revlist_args, 1);
+
        if (finish_command(&exporter))
                die("Error while running fast-export");
        push_update_refs_status(data, remote_refs);
-- 
1.8.3.rc1.553.gac13664

--
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