summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2015-12-21 10:59:05 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-12-21 10:59:05 -0800
commit5d35d72fc3030360d9b717a4c755e9ec877d00e5 (patch)
tree2b5884c11d983304e5a5460624fe941c2aa7d64b /builtin
parentMerge git://ozlabs.org/~paulus/gitk (diff)
parentpush: follow the "last one wins" convention for --recurse-submodules (diff)
downloadtgif-5d35d72fc3030360d9b717a4c755e9ec877d00e5.tar.xz
Merge branch 'mc/push-recurse-submodules-config'
Add new config to avoid typing "--recurse-submodules" on each push. * mc/push-recurse-submodules-config: push: follow the "last one wins" convention for --recurse-submodules push: test that --recurse-submodules on command line overrides config push: add recurseSubmodules config option
Diffstat (limited to 'builtin')
-rw-r--r--builtin/push.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/builtin/push.c b/builtin/push.c
index 3bda430b6b..cc29277ea2 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -9,6 +9,7 @@
#include "transport.h"
#include "parse-options.h"
#include "submodule.h"
+#include "submodule-config.h"
#include "send-pack.h"
static const char * const push_usage[] = {
@@ -21,6 +22,7 @@ static int deleterefs;
static const char *receivepack;
static int verbosity;
static int progress = -1;
+static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
static struct push_cas_option cas;
@@ -452,22 +454,14 @@ static int do_push(const char *repo, int flags)
static int option_parse_recurse_submodules(const struct option *opt,
const char *arg, int unset)
{
- int *flags = opt->value;
+ int *recurse_submodules = opt->value;
- if (*flags & (TRANSPORT_RECURSE_SUBMODULES_CHECK |
- TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND))
- die("%s can only be used once.", opt->long_name);
-
- if (arg) {
- if (!strcmp(arg, "check"))
- *flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
- else if (!strcmp(arg, "on-demand"))
- *flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;
- else
- die("bad %s argument: %s", opt->long_name, arg);
- } else
- die("option %s needs an argument (check|on-demand)",
- opt->long_name);
+ if (unset)
+ *recurse_submodules = RECURSE_SUBMODULES_OFF;
+ else if (arg)
+ *recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
+ else
+ die("%s missing parameter", opt->long_name);
return 0;
}
@@ -522,6 +516,10 @@ static int git_push_config(const char *k, const char *v, void *cb)
return error("Invalid value for '%s'", k);
}
}
+ } else if (!strcmp(k, "push.recursesubmodules")) {
+ const char *value;
+ if (!git_config_get_value("push.recursesubmodules", &value))
+ recurse_submodules = parse_push_recurse_submodules_arg(k, value);
}
return git_default_config(k, v, NULL);
@@ -549,7 +547,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
0, CAS_OPT_NAME, &cas, N_("refname>:<expect"),
N_("require old value of ref to be at this value"),
PARSE_OPT_OPTARG, parseopt_push_cas_option },
- { OPTION_CALLBACK, 0, "recurse-submodules", &flags, "check|on-demand",
+ { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, N_("check|on-demand|no"),
N_("control recursive pushing of submodules"),
PARSE_OPT_OPTARG, option_parse_recurse_submodules },
OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")),
@@ -580,6 +578,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
if (deleterefs && argc < 2)
die(_("--delete doesn't make sense without any refs"));
+ if (recurse_submodules == RECURSE_SUBMODULES_CHECK)
+ flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
+ else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
+ flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;
+
if (tags)
add_refspec("refs/tags/*");