Merge branch 'jk/push-options-via-transport-fix' into next
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Feb 2018 23:41:13 +0000 (15:41 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Feb 2018 23:41:13 +0000 (15:41 -0800)
"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

1  2 
remote-curl.c
diff --combined remote-curl.c
index e11e619d0da8a3b0748ca1af7d58bce07aaf7431,c8a42614e5e536a61a12195d7569f1ae07edb98d..a7c4c9b5ff4822e36bfc43a59d113c624537297e
@@@ -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
                        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++) {