Skip to content

Commit

Permalink
Add the 'diff.ignoreSubmodules' config setting
Browse files Browse the repository at this point in the history
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Aug 9, 2010
1 parent 302ad7a commit be4f2b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,11 @@ diff.renames::
will enable basic rename detection. If set to "copies" or
"copy", it will detect copies, as well.

diff.ignoreSubmodules::
Sets the default value of --ignore-submodules. Note that this
affects only 'git diff' Porcelain, and not lower level 'diff'
commands such as 'git diff-files'.

diff.suppressBlankEmpty::
A boolean to inhibit the standard behavior of printing a space
before each empty output line. Defaults to false.
Expand Down Expand Up @@ -1754,7 +1759,7 @@ submodule.<name>.ignore::
submodules that have untracked files in their work tree as changed.
This setting overrides any setting made in .gitmodules for this submodule,
both settings can be overriden on the command line by using the
"--ignore-submodule" option.
"--ignore-submodules" option.

tar.umask::
This variable can be used to restrict the permission bits of
Expand Down
6 changes: 5 additions & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static const char *external_diff_cmd_cfg;
int diff_auto_refresh_index = 1;
static int diff_mnemonic_prefix;
static int diff_no_prefix;
static struct diff_options default_diff_options;

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

if (!strcmp(var, "diff.ignoresubmodules"))
handle_ignore_submodules_arg(&default_diff_options, value);

return git_diff_basic_config(var, value, cb);
}

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

void diff_setup(struct diff_options *options)
{
memset(options, 0, sizeof(*options));
memcpy(options, &default_diff_options, sizeof(*options));
memset(&diff_queued_diff, 0, sizeof(diff_queued_diff));

options->file = stdout;
Expand Down
4 changes: 4 additions & 0 deletions submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ int parse_submodule_config_option(const char *var, const char *value)
void handle_ignore_submodules_arg(struct diff_options *diffopt,
const char *arg)
{
DIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES);
DIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
DIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);

if (!strcmp(arg, "all"))
DIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);
else if (!strcmp(arg, "untracked"))
Expand Down

0 comments on commit be4f2b4

Please sign in to comment.