Skip to content

Commit be4f2b4

Browse files
dschogitster
authored andcommitted
Add the 'diff.ignoreSubmodules' config setting
When you have a lot of submodules checked out, the time penalty to check for dirty submodules can easily imply a multiplication of the total time by the factor 20. This makes the difference between almost instantaneous (< 2 seconds) and unbearably slow (> 50 seconds) here, since the disk caches are constantly overloaded. To this end, the submodule.*.ignore config option was introduced, but it is per-submodule. This commit introduces a global config setting to set a default (porcelain) value for the --ignore-submodules option, keeping the default at 'none'. It can be overridden by the submodule.*.ignore setting and by the --ignore-submodules option. Incidentally, this commit fixes an issue with the overriding logic: multiple --ignore-submodules options would not clear the previously set flags. While at it, fix a typo in the documentation for submodule.*.ignore. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 302ad7a commit be4f2b4

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Documentation/config.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,11 @@ diff.renames::
826826
will enable basic rename detection. If set to "copies" or
827827
"copy", it will detect copies, as well.
828828

829+
diff.ignoreSubmodules::
830+
Sets the default value of --ignore-submodules. Note that this
831+
affects only 'git diff' Porcelain, and not lower level 'diff'
832+
commands such as 'git diff-files'.
833+
829834
diff.suppressBlankEmpty::
830835
A boolean to inhibit the standard behavior of printing a space
831836
before each empty output line. Defaults to false.
@@ -1754,7 +1759,7 @@ submodule.<name>.ignore::
17541759
submodules that have untracked files in their work tree as changed.
17551760
This setting overrides any setting made in .gitmodules for this submodule,
17561761
both settings can be overriden on the command line by using the
1757-
"--ignore-submodule" option.
1762+
"--ignore-submodules" option.
17581763

17591764
tar.umask::
17601765
This variable can be used to restrict the permission bits of

diff.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static const char *external_diff_cmd_cfg;
3131
int diff_auto_refresh_index = 1;
3232
static int diff_mnemonic_prefix;
3333
static int diff_no_prefix;
34+
static struct diff_options default_diff_options;
3435

3536
static char diff_colors[][COLOR_MAXLEN] = {
3637
GIT_COLOR_RESET,
@@ -107,6 +108,9 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
107108
if (!strcmp(var, "diff.wordregex"))
108109
return git_config_string(&diff_word_regex_cfg, var, value);
109110

111+
if (!strcmp(var, "diff.ignoresubmodules"))
112+
handle_ignore_submodules_arg(&default_diff_options, value);
113+
110114
return git_diff_basic_config(var, value, cb);
111115
}
112116

@@ -2816,7 +2820,7 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
28162820

28172821
void diff_setup(struct diff_options *options)
28182822
{
2819-
memset(options, 0, sizeof(*options));
2823+
memcpy(options, &default_diff_options, sizeof(*options));
28202824
memset(&diff_queued_diff, 0, sizeof(diff_queued_diff));
28212825

28222826
options->file = stdout;

submodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ int parse_submodule_config_option(const char *var, const char *value)
123123
void handle_ignore_submodules_arg(struct diff_options *diffopt,
124124
const char *arg)
125125
{
126+
DIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES);
127+
DIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
128+
DIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);
129+
126130
if (!strcmp(arg, "all"))
127131
DIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);
128132
else if (!strcmp(arg, "untracked"))

0 commit comments

Comments
 (0)