Merge branch 'bc/sha1-header-selection-with-cpp-macros'
[gitweb.git] / builtin / push.c
index 00a1b684830c0201361b9ec84d874aaa40b2a9e0..5c22e9f2e56b7d8049890e44f4c6fb63b16f8357 100644 (file)
@@ -356,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);
@@ -379,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"));
@@ -409,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++;
        }
@@ -503,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 */
+       static struct string_list push_options = STRING_LIST_INIT_DUP;
+       static struct string_list_item *item;
+
        struct option options[] = {
                OPT__VERBOSITY(&verbosity),
                OPT_STRING( 0 , "repo", &repo, N_("repository"), N_("repository")),
@@ -536,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"),
@@ -557,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/*");
@@ -566,7 +579,11 @@ 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);
        if (rc == -1)
                usage_with_options(push_usage, options);
        else