diff options
Diffstat (limited to 'transport-helper.c')
-rw-r--r-- | transport-helper.c | 87 |
1 files changed, 63 insertions, 24 deletions
diff --git a/transport-helper.c b/transport-helper.c index 4208743605..36408046eb 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -124,8 +124,9 @@ static struct child_process *get_helper(struct transport *transport) helper->git_cmd = 0; helper->silent_exec_failure = 1; - argv_array_pushf(&helper->env_array, "%s=%s", GIT_DIR_ENVIRONMENT, - get_git_dir()); + if (have_git_dir()) + argv_array_pushf(&helper->env_array, "%s=%s", + GIT_DIR_ENVIRONMENT, get_git_dir()); code = start_command(helper); if (code < 0 && errno == ENOENT) @@ -258,8 +259,51 @@ static const char *boolean_options[] = { TRANS_OPT_THIN, TRANS_OPT_KEEP, TRANS_OPT_FOLLOWTAGS, + TRANS_OPT_DEEPEN_RELATIVE }; +static int strbuf_set_helper_option(struct helper_data *data, + struct strbuf *buf) +{ + int ret; + + sendline(data, buf); + if (recvline(data, buf)) + exit(128); + + if (!strcmp(buf->buf, "ok")) + ret = 0; + else if (starts_with(buf->buf, "error")) + ret = -1; + else if (!strcmp(buf->buf, "unsupported")) + ret = 1; + else { + warning("%s unexpectedly said: '%s'", data->name, buf->buf); + ret = 1; + } + return ret; +} + +static int string_list_set_helper_option(struct helper_data *data, + const char *name, + struct string_list *list) +{ + struct strbuf buf = STRBUF_INIT; + int i, ret = 0; + + for (i = 0; i < list->nr; i++) { + strbuf_addf(&buf, "option %s ", name); + quote_c_style(list->items[i].string, &buf, NULL, 0); + strbuf_addch(&buf, '\n'); + + if ((ret = strbuf_set_helper_option(data, &buf))) + break; + strbuf_reset(&buf); + } + strbuf_release(&buf); + return ret; +} + static int set_helper_option(struct transport *transport, const char *name, const char *value) { @@ -272,6 +316,10 @@ static int set_helper_option(struct transport *transport, if (!data->option) return 1; + if (!strcmp(name, "deepen-not")) + return string_list_set_helper_option(data, name, + (struct string_list *)value); + for (i = 0; i < ARRAY_SIZE(unsupported_options); i++) { if (!strcmp(name, unsupported_options[i])) return 1; @@ -291,20 +339,7 @@ static int set_helper_option(struct transport *transport, quote_c_style(value, &buf, NULL, 0); strbuf_addch(&buf, '\n'); - sendline(data, &buf); - if (recvline(data, &buf)) - exit(128); - - if (!strcmp(buf.buf, "ok")) - ret = 0; - else if (starts_with(buf.buf, "error")) { - ret = -1; - } else if (!strcmp(buf.buf, "unsupported")) - ret = 1; - else { - warning("%s unexpectedly said: '%s'", data->name, buf.buf); - ret = 1; - } + ret = strbuf_set_helper_option(data, &buf); strbuf_release(&buf); return ret; } @@ -312,14 +347,11 @@ static int set_helper_option(struct transport *transport, static void standard_options(struct transport *t) { char buf[16]; - int n; int v = t->verbose; set_helper_option(t, "progress", t->progress ? "true" : "false"); - n = snprintf(buf, sizeof(buf), "%d", v + 1); - if (n >= sizeof(buf)) - die("impossibly large verbosity value"); + xsnprintf(buf, sizeof(buf), "%d", v + 1); set_helper_option(t, "verbosity", buf); switch (t->family) { @@ -792,6 +824,13 @@ static void set_common_push_options(struct transport *transport, if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "if-asked") != 0) die("helper %s does not support --signed=if-asked", name); } + + if (flags & TRANSPORT_PUSH_OPTIONS) { + struct string_list_item *item; + for_each_string_list_item(item, transport->push_options) + if (set_helper_option(transport, "push-option", item->string) != 0) + die("helper %s does not support 'push-option'", name); + } } static int push_refs_with_push(struct transport *transport, @@ -1103,7 +1142,7 @@ static void transfer_debug(const char *fmt, ...) } /* Stream state: More data may be coming in this direction. */ -#define SSTATE_TRANSFERING 0 +#define SSTATE_TRANSFERRING 0 /* * Stream state: No more data coming in this direction, flushing rest of * data. @@ -1112,7 +1151,7 @@ static void transfer_debug(const char *fmt, ...) /* Stream state: Transfer in this direction finished. */ #define SSTATE_FINISHED 2 -#define STATE_NEEDS_READING(state) ((state) <= SSTATE_TRANSFERING) +#define STATE_NEEDS_READING(state) ((state) <= SSTATE_TRANSFERRING) #define STATE_NEEDS_WRITING(state) ((state) <= SSTATE_FLUSHING) #define STATE_NEEDS_CLOSING(state) ((state) == SSTATE_FLUSHING) @@ -1369,7 +1408,7 @@ int bidirectional_transfer_loop(int input, int output) state.ptg.dest = 1; state.ptg.src_is_sock = (input == output); state.ptg.dest_is_sock = 0; - state.ptg.state = SSTATE_TRANSFERING; + state.ptg.state = SSTATE_TRANSFERRING; state.ptg.bufuse = 0; state.ptg.src_name = "remote input"; state.ptg.dest_name = "stdout"; @@ -1378,7 +1417,7 @@ int bidirectional_transfer_loop(int input, int output) state.gtp.dest = output; state.gtp.src_is_sock = 0; state.gtp.dest_is_sock = (input == output); - state.gtp.state = SSTATE_TRANSFERING; + state.gtp.state = SSTATE_TRANSFERRING; state.gtp.bufuse = 0; state.gtp.src_name = "stdin"; state.gtp.dest_name = "remote output"; |