diff options
Diffstat (limited to 'transport-helper.c')
-rw-r--r-- | transport-helper.c | 85 |
1 files changed, 63 insertions, 22 deletions
diff --git a/transport-helper.c b/transport-helper.c index 13b7a57a75..1258d6aedd 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -258,8 +258,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 +315,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 +338,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; } @@ -792,6 +826,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, @@ -1038,7 +1079,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push) (*tail)->status |= REF_STATUS_UPTODATE; if (read_ref((*tail)->name, (*tail)->old_oid.hash) < 0) - die(N_("Could not read ref %s"), + die(_("Could not read ref %s"), (*tail)->name); } } @@ -1103,7 +1144,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 +1153,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) @@ -1166,7 +1207,7 @@ static int udt_do_read(struct unidirectional_transfer *t) bytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse); if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR) { - error("read(%s) failed: %s", t->src_name, strerror(errno)); + error_errno("read(%s) failed", t->src_name); return -1; } else if (bytes == 0) { transfer_debug("%s EOF (with %i bytes in buffer)", @@ -1193,7 +1234,7 @@ static int udt_do_write(struct unidirectional_transfer *t) transfer_debug("%s is writable", t->dest_name); bytes = xwrite(t->dest, t->buf, t->bufuse); if (bytes < 0 && errno != EWOULDBLOCK) { - error("write(%s) failed: %s", t->dest_name, strerror(errno)); + error_errno("write(%s) failed", t->dest_name); return -1; } else if (bytes > 0) { t->bufuse -= bytes; @@ -1306,7 +1347,7 @@ static int tloop_join(pid_t pid, const char *name) { int tret; if (waitpid(pid, &tret, 0) < 0) { - error("%s process failed to wait: %s", name, strerror(errno)); + error_errno("%s process failed to wait", name); return 1; } if (!WIFEXITED(tret) || WEXITSTATUS(tret)) { @@ -1369,7 +1410,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 +1419,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"; |