transport-helper: add support for old:new refspec
By using fast-export's new --refspec option. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 20, 2014 at 13:59 UTC
d98c81538015630603fd20f6e08e960555a38c52
2 files changed
+11
-4
t/t5801-remote-helpers.sh
+1
-1
@@ -87,7 +87,7 @@ test_expect_success 'push new branch by name' '
87
compare_refs local HEAD server refs/heads/new-name
88
'
89
90
-test_expect_failure 'push new branch with old:new refspec' '
90
+test_expect_success 'push new branch with old:new refspec' '
91
(cd local &&
92
git push origin new-name:new-refspec
93
) &&
transport-helper.c
+10
-3
@@ -856,7 +856,7 @@ static int push_refs_with_export(struct transport *transport,
856
struct ref *ref;
857
struct child_process *helper, exporter;
858
struct helper_data *data = transport->data;
859
- struct string_list revlist_args = STRING_LIST_INIT_NODUP;
859
+ struct string_list revlist_args = STRING_LIST_INIT_DUP;
860
struct strbuf buf = STRBUF_INIT;
861
862
if (!data->refspecs)
@@ -894,8 +894,13 @@ static int push_refs_with_export(struct transport *transport,
894
free(private);
895
896
if (ref->peer_ref) {
897
- if (strcmp(ref->peer_ref->name, ref->name))
898
- die("remote-helpers do not support old:new syntax");
897
+ if (strcmp(ref->name, ref->peer_ref->name)) {
898
+ struct strbuf buf = STRBUF_INIT;
899
+ strbuf_addf(&buf, "%s:%s", ref->peer_ref->name, ref->name);
900
+ string_list_append(&revlist_args, "--refspec");
901
+ string_list_append(&revlist_args, buf.buf);
902
+ strbuf_release(&buf);
903
+ }
904
string_list_append(&revlist_args, ref->peer_ref->name);
905
}
906
}
@@ -903,6 +908,8 @@ static int push_refs_with_export(struct transport *transport,
908
if (get_exporter(transport, &exporter, &revlist_args))
909
die("Couldn't run fast-export");
910
911
+ string_list_clear(&revlist_args, 1);
912
+
913
if (finish_command(&exporter))
914
die("Error while running fast-export");
915
push_update_refs_status(data, remote_refs, flags);