diff options
Diffstat (limited to 'transport-helper.c')
-rw-r--r-- | transport-helper.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/transport-helper.c b/transport-helper.c index 2b24d51a24..5d99a6bc2e 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -5,7 +5,6 @@ #include "commit.h" #include "diff.h" #include "revision.h" -#include "quote.h" #include "remote.h" #include "string-list.h" #include "thread-utils.h" @@ -98,6 +97,8 @@ static void do_take_over(struct transport *transport) free(data); } +static void standard_options(struct transport *t); + static struct child_process *get_helper(struct transport *transport) { struct helper_data *data = transport->data; @@ -108,12 +109,6 @@ static struct child_process *get_helper(struct transport *transport) int refspec_alloc = 0; int duped; int code; - char git_dir_buf[sizeof(GIT_DIR_ENVIRONMENT) + PATH_MAX + 1]; - const char *helper_env[] = { - git_dir_buf, - NULL - }; - if (data->helper) return data->helper; @@ -129,8 +124,8 @@ static struct child_process *get_helper(struct transport *transport) helper->git_cmd = 0; helper->silent_exec_failure = 1; - snprintf(git_dir_buf, sizeof(git_dir_buf), "%s=%s", GIT_DIR_ENVIRONMENT, get_git_dir()); - helper->env = helper_env; + argv_array_pushf(&helper->env_array, "%s=%s", GIT_DIR_ENVIRONMENT, + get_git_dir()); code = start_command(helper); if (code < 0 && errno == ENOENT) @@ -218,6 +213,7 @@ static struct child_process *get_helper(struct transport *transport) strbuf_release(&buf); if (debug) fprintf(stderr, "Debug: Capabilities complete.\n"); + standard_options(transport); return data->helper; } @@ -345,24 +341,14 @@ static int fetch_with_fetch(struct transport *transport, int i; struct strbuf buf = STRBUF_INIT; - standard_options(transport); - if (data->check_connectivity && - data->transport_options.check_self_contained_and_connected) - set_helper_option(transport, "check-connectivity", "true"); - - if (transport->cloning) - set_helper_option(transport, "cloning", "true"); - - if (data->transport_options.update_shallow) - set_helper_option(transport, "update-shallow", "true"); - for (i = 0; i < nr_heads; i++) { const struct ref *posn = to_fetch[i]; if (posn->status & REF_STATUS_UPTODATE) continue; strbuf_addf(&buf, "fetch %s %s\n", - sha1_to_hex(posn->old_sha1), posn->name); + sha1_to_hex(posn->old_sha1), + posn->symref ? posn->symref : posn->name); } strbuf_addch(&buf, '\n'); @@ -420,7 +406,7 @@ static int get_exporter(struct transport *transport, struct child_process *helper = get_helper(transport); int i; - memset(fastexport, 0, sizeof(*fastexport)); + child_process_init(fastexport); /* we need to duplicate helper->in because we want to use it after * fastexport is done with it. */ @@ -460,7 +446,8 @@ static int fetch_with_import(struct transport *transport, if (posn->status & REF_STATUS_UPTODATE) continue; - strbuf_addf(&buf, "import %s\n", posn->name); + strbuf_addf(&buf, "import %s\n", + posn->symref ? posn->symref : posn->name); sendline(data, &buf); strbuf_reset(&buf); } @@ -493,14 +480,15 @@ static int fetch_with_import(struct transport *transport, * fast-forward or this is a forced update. */ for (i = 0; i < nr_heads; i++) { - char *private; + char *private, *name; posn = to_fetch[i]; if (posn->status & REF_STATUS_UPTODATE) continue; + name = posn->symref ? posn->symref : posn->name; if (data->refspecs) - private = apply_refspecs(data->refspecs, data->refspec_nr, posn->name); + private = apply_refspecs(data->refspecs, data->refspec_nr, name); else - private = xstrdup(posn->name); + private = xstrdup(name); if (private) { read_ref(private, posn->old_sha1); free(private); @@ -626,6 +614,16 @@ static int fetch(struct transport *transport, if (!count) return 0; + if (data->check_connectivity && + data->transport_options.check_self_contained_and_connected) + set_helper_option(transport, "check-connectivity", "true"); + + if (transport->cloning) + set_helper_option(transport, "cloning", "true"); + + if (data->transport_options.update_shallow) + set_helper_option(transport, "update-shallow", "true"); + if (data->fetch) return fetch_with_fetch(transport, nr_heads, to_fetch); @@ -830,7 +828,6 @@ static int push_refs_with_push(struct transport *transport, return 0; } - standard_options(transport); for_each_string_list_item(cas_option, &cas_options) set_helper_option(transport, "cas", cas_option->string); @@ -866,7 +863,7 @@ static int push_refs_with_export(struct transport *transport, die("helper %s does not support dry-run", data->name); } else if (flags & TRANSPORT_PUSH_CERT) { if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "true") != 0) - die("helper %s does not support dry-run", data->name); + die("helper %s does not support --signed", data->name); } if (flags & TRANSPORT_PUSH_FORCE) { @@ -897,7 +894,10 @@ static int push_refs_with_export(struct transport *transport, int flag; /* Follow symbolic refs (mainly for HEAD). */ - name = resolve_ref_unsafe(ref->peer_ref->name, sha1, 1, &flag); + name = resolve_ref_unsafe( + ref->peer_ref->name, + RESOLVE_REF_READING, + sha1, &flag); if (!name || !(flag & REF_ISSYMREF)) name = ref->peer_ref->name; |