Am 02.10.2012 18:51, schrieb Ramkumar Ramachandra:
Introduce a diff.submoduleFormat configuration variable corresponding
to the '--submodule' command-line option of 'git diff'.
Nice. Maybe a better name would be diff.submodule, as this sets the
default for the --submodule option of diff?
And I think you should also test in t4041 that --submodule=short
overrides the config setting.
Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
---
Documentation/diff-config.txt|7 +++
Documentation/diff-options.txt |3 ++-
diff.c | 25 -
t/t4041-diff-submodule-option.sh | 10 ++
4 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
index 04574f9..e445cc8 100644
--- a/Documentation/diff-config.txt
+++ b/Documentation/diff-config.txt
@@ -103,6 +103,13 @@ diff.suppressBlankEmpty::
A boolean to inhibit the standard behavior of printing a space
before each empty output line. Defaults to false.
+diff.submoduleFormat::
+ Specify the format in which differences in submodules are
+ shown. The log format lists the commits in the range like
+ linkgit:git-submodule[1] `summary` does. The short format
+ format just shows the names of the commits at the beginning
+ and end of the range. Defaults to short.
+
diff.wordRegex::
A POSIX Extended Regular Expression used to determine what is a word
when performing word-by-word difference calculations. Character
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index cf4b216..034c4e7 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -170,7 +170,8 @@ any of those replacements occurred.
the commits in the range like linkgit:git-submodule[1] `summary` does.
Omitting the `--submodule` option or specifying `--submodule=short`,
uses the 'short' format. This format just shows the names of the commits
- at the beginning and end of the range.
+ at the beginning and end of the range. Can be tweaked via the
+ `diff.submoduleFormat` configuration variable.
--color[=when]::
Show colored diff.
diff --git a/diff.c b/diff.c
index 8ea40f9..4cb8dd2 100644
--- a/diff.c
+++ b/diff.c
@@ -28,6 +28,7 @@ static int diff_suppress_blank_empty;
static int diff_use_color_default = -1;
static const char *diff_word_regex_cfg;
static const char *external_diff_cmd_cfg;
+static const char *submodule_format_cfg;
int diff_auto_refresh_index = 1;
static int diff_mnemonic_prefix;
static int diff_no_prefix;
@@ -161,6 +162,8 @@ int git_diff_ui_config(const char *var, const char
*value, void *cb)
diff_stat_graph_width = git_config_int(var, value);
return 0;
}
+ if (!strcmp(var, diff.submoduleformat))
+ return git_config_string(submodule_format_cfg, var, value);
if (!strcmp(var, diff.external))
return git_config_string(external_diff_cmd_cfg, var, value);
if (!strcmp(var, diff.wordregex))
@@ -2227,15 +2230,19 @@ static void builtin_diff(const char *name_a,
line_prefix = msgbuf-buf;
}
- if (DIFF_OPT_TST(o, SUBMODULE_LOG)
- (!one-mode || S_ISGITLINK(one-mode))
- (!two-mode || S_ISGITLINK(two-mode))) {
- const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
- const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
- show_submodule_summary(o-file, one ? one-path : two-path,
- one-sha1, two-sha1, two-dirty_submodule,
- del, add, reset);
- return;
+ if (!DIFF_OPT_TST(o, SUBMODULE_SHORT)
+ ((!one-mode || S_ISGITLINK(one-mode))
+ (!two-mode || S_ISGITLINK(two-mode {
+ if (DIFF_OPT_TST(o, SUBMODULE_LOG) ||
+ (submodule_format_cfg
+ !strcmp(submodule_format_cfg, log))) {
+ const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
+ const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
+ show_submodule_summary(o-file, one ? one-path :
two-path,
+ one-sha1, two-sha1,
two-dirty_submodule,
+ del, add, reset);
+ return;
+ }
}
if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
diff --git a/t/t4041-diff-submodule-option.sh
b/t/t4041-diff-submodule-option.sh
index 6c01d0c..ed4f3a8 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -43,6 +43,16 @@ EOF
test_cmp expected actual
+test_expect_success 'added submodule, set diff.submoduleFormat'
+ git config