summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2012-11-13 15:42:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-11-19 03:18:13 (GMT)
commitc47ef57caaa2b17d32b343fbe652f33b31c81362 (patch)
tree9e897701dc452deee919edce5988e7169d430096 /diff.c
parent22bc70fdf90edec98012806891f1a132fcd93575 (diff)
downloadgit-c47ef57caaa2b17d32b343fbe652f33b31c81362.zip
git-c47ef57caaa2b17d32b343fbe652f33b31c81362.tar.gz
git-c47ef57caaa2b17d32b343fbe652f33b31c81362.tar.bz2
diff: introduce diff.submodule configuration variable
Introduce a diff.submodule configuration variable corresponding to the '--submodule' command-line option of 'git diff'. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/diff.c b/diff.c
index 86e5f2a..178df85 100644
--- a/diff.c
+++ b/diff.c
@@ -121,6 +121,17 @@ static int parse_dirstat_params(struct diff_options *options, const char *params
return ret;
}
+static int parse_submodule_params(struct diff_options *options, const char *value)
+{
+ if (!strcmp(value, "log"))
+ DIFF_OPT_SET(options, SUBMODULE_LOG);
+ else if (!strcmp(value, "short"))
+ DIFF_OPT_CLR(options, SUBMODULE_LOG);
+ else
+ return -1;
+ return 0;
+}
+
static int git_config_rename(const char *var, const char *value)
{
if (!value)
@@ -176,6 +187,13 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
if (!strcmp(var, "diff.ignoresubmodules"))
handle_ignore_submodules_arg(&default_diff_options, value);
+ if (!strcmp(var, "diff.submodule")) {
+ if (parse_submodule_params(&default_diff_options, value))
+ warning(_("Unknown value for 'diff.submodule' config variable: '%s'"),
+ value);
+ return 0;
+ }
+
if (git_color_config(var, value, cb) < 0)
return -1;
@@ -3473,6 +3491,14 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params)
return 1;
}
+static int parse_submodule_opt(struct diff_options *options, const char *value)
+{
+ if (parse_submodule_params(options, value))
+ die(_("Failed to parse --submodule option parameter: '%s'"),
+ value);
+ return 1;
+}
+
int diff_opt_parse(struct diff_options *options, const char **av, int ac)
{
const char *arg = av[0];
@@ -3653,10 +3679,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
handle_ignore_submodules_arg(options, arg + 20);
} else if (!strcmp(arg, "--submodule"))
DIFF_OPT_SET(options, SUBMODULE_LOG);
- else if (!prefixcmp(arg, "--submodule=")) {
- if (!strcmp(arg + 12, "log"))
- DIFF_OPT_SET(options, SUBMODULE_LOG);
- }
+ else if (!prefixcmp(arg, "--submodule="))
+ return parse_submodule_opt(options, arg + 12);
/* misc options */
else if (!strcmp(arg, "-z"))