From: Junio C Hamano Date: Wed, 28 Feb 2018 21:37:58 +0000 (-0800) Subject: Merge branch 'jk/push-options-via-transport-fix' X-Git-Tag: v2.17.0-rc0~52 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/69917e64396030bdd94e965e494d22ecb3caa6ca?ds=inline;hp=-c Merge branch 'jk/push-options-via-transport-fix' "git push" over http transport did not unquote the push-options correctly. * jk/push-options-via-transport-fix: remote-curl: unquote incoming push-options t5545: factor out http repository setup --- 69917e64396030bdd94e965e494d22ecb3caa6ca diff --combined remote-curl.c index e11e619d0d,c8a42614e5..a7c4c9b5ff --- a/remote-curl.c +++ b/remote-curl.c @@@ -13,6 -13,7 +13,7 @@@ #include "credential.h" #include "sha1-array.h" #include "send-pack.h" + #include "quote.h" static struct remote *remote; /* always ends with a trailing slash */ @@@ -24,7 -25,6 +25,7 @@@ struct options char *deepen_since; struct string_list deepen_not; struct string_list push_options; + char *filter; unsigned progress : 1, check_self_contained_and_connected : 1, cloning : 1, @@@ -34,9 -34,7 +35,9 @@@ thin : 1, /* One of the SEND_PACK_PUSH_CERT_* constants. */ push_cert : 2, - deepen_relative : 1; + deepen_relative : 1, + from_promisor : 1, + no_dependents : 1; }; static struct options options; static struct string_list cas_options = STRING_LIST_INIT_DUP; @@@ -145,7 -143,15 +146,15 @@@ static int set_option(const char *name return -1; return 0; } else if (!strcmp(name, "push-option")) { - string_list_append(&options.push_options, value); + if (*value != '"') + string_list_append(&options.push_options, value); + else { + struct strbuf unquoted = STRBUF_INIT; + if (unquote_c_style(&unquoted, value, NULL) < 0) + die("invalid quoting in push-option value"); + string_list_append_nodup(&options.push_options, + strbuf_detach(&unquoted, NULL)); + } return 0; #if LIBCURL_VERSION_NUM >= 0x070a08 @@@ -160,15 -166,6 +169,15 @@@ return -1; return 0; #endif /* LIBCURL_VERSION_NUM >= 0x070a08 */ + } else if (!strcmp(name, "from-promisor")) { + options.from_promisor = 1; + return 0; + } else if (!strcmp(name, "no-dependents")) { + options.no_dependents = 1; + return 0; + } else if (!strcmp(name, "filter")) { + options.filter = xstrdup(value);; + return 0; } else { return 1 /* unsupported */; } @@@ -351,8 -348,6 +360,8 @@@ static struct discovery *discover_refs( * pkt-line matches our request. */ line = packet_read_line_buf(&last->buf, &last->len, NULL); + if (!line) + die("invalid server response; expected service, got flush packet"); strbuf_reset(&exp); strbuf_addf(&exp, "# service=%s", service); @@@ -836,12 -831,6 +845,12 @@@ static int fetch_git(struct discovery * options.deepen_not.items[i].string); if (options.deepen_relative && options.depth) argv_array_push(&args, "--deepen-relative"); + if (options.from_promisor) + argv_array_push(&args, "--from-promisor"); + if (options.no_dependents) + argv_array_push(&args, "--no-dependents"); + if (options.filter) + argv_array_pushf(&args, "--filter=%s", options.filter); argv_array_push(&args, url.buf); for (i = 0; i < nr_heads; i++) {