@matheusbsbs / matheus-bagliano / commits / be4f2b408e
Fork 0

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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Aug 5, 2010 at 10:49 UTC be4f2b408e5a00d123a0ecb04b0c6c48be71dfa1
3 files changed +15 -2
Documentation/config.txt
+6 -1
@@ -826,6 +826,11 @@ diff.renames::
826 will enable basic rename detection. If set to "copies" or
827 "copy", it will detect copies, as well.
828
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 +
834 diff.suppressBlankEmpty::
835 A boolean to inhibit the standard behavior of printing a space
836 before each empty output line. Defaults to false.
@@ -1754,7 +1759,7 @@ submodule.<name>.ignore::
1759 submodules that have untracked files in their work tree as changed.
1760 This setting overrides any setting made in .gitmodules for this submodule,
1761 both settings can be overriden on the command line by using the
1757 - "--ignore-submodule" option.
1762 + "--ignore-submodules" option.
1763
1764 tar.umask::
1765 This variable can be used to restrict the permission bits of
diff.c
+5 -1
@@ -31,6 +31,7 @@ static const char *external_diff_cmd_cfg;
31 int diff_auto_refresh_index = 1;
32 static int diff_mnemonic_prefix;
33 static int diff_no_prefix;
34 +static struct diff_options default_diff_options;
35
36 static char diff_colors[][COLOR_MAXLEN] = {
37 GIT_COLOR_RESET,
@@ -107,6 +108,9 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
108 if (!strcmp(var, "diff.wordregex"))
109 return git_config_string(&diff_word_regex_cfg, var, value);
110
111 + if (!strcmp(var, "diff.ignoresubmodules"))
112 + handle_ignore_submodules_arg(&default_diff_options, value);
113 +
114 return git_diff_basic_config(var, value, cb);
115 }
116
@@ -2816,7 +2820,7 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
2820
2821 void diff_setup(struct diff_options *options)
2822 {
2819 - memset(options, 0, sizeof(*options));
2823 + memcpy(options, &default_diff_options, sizeof(*options));
2824 memset(&diff_queued_diff, 0, sizeof(diff_queued_diff));
2825
2826 options->file = stdout;
submodule.c
+4
@@ -123,6 +123,10 @@ int parse_submodule_config_option(const char *var, const char *value)
123 void handle_ignore_submodules_arg(struct diff_options *diffopt,
124 const char *arg)
125 {
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 +
130 if (!strcmp(arg, "all"))
131 DIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);
132 else if (!strcmp(arg, "untracked"))