summaryrefslogtreecommitdiff
path: root/transport-helper.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-06-16 19:18:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-16 19:18:15 (GMT)
commitc9fc3a6ac5011ce03e8132973687d1242807dc6c (patch)
tree9d8a40b578307a5be129f5385ad28fea3d8e8bad /transport-helper.c
parent1a81f6ceea7795e2b78cebd356d276afe79e7626 (diff)
parente143ef4f6b08e0f948180f28ad3ba77c9a2e0a61 (diff)
downloadgit-c9fc3a6ac5011ce03e8132973687d1242807dc6c.zip
git-c9fc3a6ac5011ce03e8132973687d1242807dc6c.tar.gz
git-c9fc3a6ac5011ce03e8132973687d1242807dc6c.tar.bz2
Merge branch 'fc/remote-helper-refmap'
Allow remote-helper/fast-import based transport to rename the refs while transferring the history. * fc/remote-helper-refmap: transport-helper: remove unnecessary strbuf resets transport-helper: add support to delete branches fast-export: add support to delete refs fast-import: add support to delete refs transport-helper: add support to push symbolic refs transport-helper: add support for old:new refspec fast-export: add new --refspec option fast-export: improve argument parsing
Diffstat (limited to 'transport-helper.c')
-rw-r--r--transport-helper.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/transport-helper.c b/transport-helper.c
index 4cfb8f3..84c616f 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -850,7 +850,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)
@@ -870,15 +870,10 @@ static int push_refs_with_export(struct transport *transport,
write_constant(helper->in, "export\n");
- strbuf_reset(&buf);
-
for (ref = remote_refs; ref; ref = ref->next) {
char *private;
unsigned char sha1[20];
- if (ref->deletion)
- die("remote-helpers do not support ref deletion");
-
private = apply_refspecs(data->refspecs, data->refspec_nr, ref->name);
if (private && !get_sha1(private, sha1)) {
strbuf_addf(&buf, "^%s", private);
@@ -888,15 +883,34 @@ 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");
- string_list_append(&revlist_args, ref->peer_ref->name);
+ if (strcmp(ref->name, ref->peer_ref->name)) {
+ if (!ref->deletion) {
+ 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);
+ } else
+ strbuf_addf(&buf, ":%s", ref->name);
+
+ string_list_append(&revlist_args, "--refspec");
+ string_list_append(&revlist_args, buf.buf);
+ strbuf_release(&buf);
+ }
+ if (!ref->deletion)
+ 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");
if (push_update_refs_status(data, remote_refs, flags))