Skip to content

Commit

Permalink
transport-helper: add support for old:new refspec
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed Apr 21, 2014
1 parent 03e9010 commit d98c815
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion t/t5801-remote-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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
) &&
Expand Down
13 changes: 10 additions & 3 deletions transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,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;

if (!data->refspecs)
Expand Down Expand Up @@ -894,15 +894,22 @@ static int push_refs_with_export(struct transport *transport,
free(private);

if (ref->peer_ref) {
if (strcmp(ref->peer_ref->name, ref->name))
die("remote-helpers do not support old:new syntax");
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, flags);
Expand Down

0 comments on commit d98c815

Please sign in to comment.