summaryrefslogtreecommitdiff
path: root/submodule-config.c
diff options
context:
space:
mode:
authorLibravatar Mike Crowe <mac@mcrowe.com>2015-11-17 11:05:56 +0000
committerLibravatar Jeff King <peff@peff.net>2015-11-20 08:02:07 -0500
commitb33a15b08131514b593015cb3e719faf9db20208 (patch)
treea386c39c022d11a41f9107613cccfe05df005d01 /submodule-config.c
parentMerge branch 'master' of git://git.bogomips.org/git-svn (diff)
downloadtgif-b33a15b08131514b593015cb3e719faf9db20208.tar.xz
push: add recurseSubmodules config option
The --recurse-submodules command line parameter has existed for some time but it has no config file equivalent. Following the style of the corresponding parameter for git fetch, let's invent push.recurseSubmodules to provide a default for this parameter. This also requires the addition of --recurse-submodules=no to allow the configuration to be overridden on the command line when required. The most straightforward way to implement this appears to be to make push use code in submodule-config in a similar way to fetch. Signed-off-by: Mike Crowe <mac@mcrowe.com> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'submodule-config.c')
-rw-r--r--submodule-config.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/submodule-config.c b/submodule-config.c
index afe0ea8156..fe8ceabf30 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -228,6 +228,35 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
return parse_fetch_recurse(opt, arg, 1);
}
+static int parse_push_recurse(const char *opt, const char *arg,
+ int die_on_error)
+{
+ switch (git_config_maybe_bool(opt, arg)) {
+ case 1:
+ /* There's no simple "on" value when pushing */
+ if (die_on_error)
+ die("bad %s argument: %s", opt, arg);
+ else
+ return RECURSE_SUBMODULES_ERROR;
+ case 0:
+ return RECURSE_SUBMODULES_OFF;
+ default:
+ if (!strcmp(arg, "on-demand"))
+ return RECURSE_SUBMODULES_ON_DEMAND;
+ else if (!strcmp(arg, "check"))
+ return RECURSE_SUBMODULES_CHECK;
+ else if (die_on_error)
+ die("bad %s argument: %s", opt, arg);
+ else
+ return RECURSE_SUBMODULES_ERROR;
+ }
+}
+
+int parse_push_recurse_submodules_arg(const char *opt, const char *arg)
+{
+ return parse_push_recurse(opt, arg, 1);
+}
+
static void warn_multiple_config(const unsigned char *commit_sha1,
const char *name, const char *option)
{