t0302 & t3900: add forgotten quotes
[gitweb.git] / builtin / push.c
index 4e9e4dbab23e5fb78239eadde724a63240e43505..a597759d8fac205f41c406d0a0e32f9240941190 100644 (file)
@@ -194,15 +194,18 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,
                        die_push_simple(branch, remote);
        }
 
-       strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
+       strbuf_addf(&refspec, "%s:%s", branch->refname, branch->merge[0]->src);
        add_refspec(refspec.buf);
 }
 
 static void setup_push_current(struct remote *remote, struct branch *branch)
 {
+       struct strbuf refspec = STRBUF_INIT;
+
        if (!branch)
                die(_(message_detached_head_die), remote->name);
-       add_refspec(branch->name);
+       strbuf_addf(&refspec, "%s:%s", branch->refname, branch->refname);
+       add_refspec(refspec.buf);
 }
 
 static int is_workflow_triangular(struct remote *remote)
@@ -353,7 +356,8 @@ static int push_with_options(struct transport *transport, int flags)
        return 1;
 }
 
-static int do_push(const char *repo, int flags)
+static int do_push(const char *repo, int flags,
+                  const struct string_list *push_options)
 {
        int i, errs;
        struct remote *remote = pushremote_get(repo);
@@ -376,6 +380,9 @@ static int do_push(const char *repo, int flags)
        if (remote->mirror)
                flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
 
+       if (push_options->nr)
+               flags |= TRANSPORT_PUSH_OPTIONS;
+
        if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
                if (!strcmp(*refspec, "refs/tags/*"))
                        return error(_("--all and --tags are incompatible"));
@@ -406,13 +413,16 @@ static int do_push(const char *repo, int flags)
                for (i = 0; i < url_nr; i++) {
                        struct transport *transport =
                                transport_get(remote, url[i]);
+                       if (flags & TRANSPORT_PUSH_OPTIONS)
+                               transport->push_options = push_options;
                        if (push_with_options(transport, flags))
                                errs++;
                }
        } else {
                struct transport *transport =
                        transport_get(remote, NULL);
-
+               if (flags & TRANSPORT_PUSH_OPTIONS)
+                       transport->push_options = push_options;
                if (push_with_options(transport, flags))
                        errs++;
        }
@@ -500,6 +510,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)
        int push_cert = -1;
        int rc;
        const char *repo = NULL;        /* default repository */
+       struct string_list push_options = STRING_LIST_INIT_DUP;
+       const struct string_list_item *item;
+
        struct option options[] = {
                OPT__VERBOSITY(&verbosity),
                OPT_STRING( 0 , "repo", &repo, N_("repository"), N_("repository")),
@@ -533,6 +546,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
                  0, "signed", &push_cert, "yes|no|if-asked", N_("GPG sign the push"),
                  PARSE_OPT_OPTARG, option_parse_push_signed },
                OPT_BIT(0, "atomic", &flags, N_("request atomic transaction on remote side"), TRANSPORT_PUSH_ATOMIC),
+               OPT_STRING_LIST('o', "push-option", &push_options, N_("server-specific"), N_("option to transmit")),
                OPT_SET_INT('4', "ipv4", &family, N_("use IPv4 addresses only"),
                                TRANSPORT_FAMILY_IPV4),
                OPT_SET_INT('6', "ipv6", &family, N_("use IPv6 addresses only"),
@@ -554,6 +568,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
                flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
        else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
                flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;
+       else if (recurse_submodules == RECURSE_SUBMODULES_ONLY)
+               flags |= TRANSPORT_RECURSE_SUBMODULES_ONLY;
 
        if (tags)
                add_refspec("refs/tags/*");
@@ -563,7 +579,12 @@ int cmd_push(int argc, const char **argv, const char *prefix)
                set_refspecs(argv + 1, argc - 1, repo);
        }
 
-       rc = do_push(repo, flags);
+       for_each_string_list_item(item, &push_options)
+               if (strchr(item->string, '\n'))
+                       die(_("push options must not have new line characters"));
+
+       rc = do_push(repo, flags, &push_options);
+       string_list_clear(&push_options, 0);
        if (rc == -1)
                usage_with_options(push_usage, options);
        else