git diff: Don't test submodule dirtiness with --ignore-submodules
The diff family suppresses the output of submodule changes when requested but checks them nonetheless. But since recently submodules get examined for their dirtiness, which is rather expensive. There is no need to do that when the --ignore-submodules option is used, as the gathered information is never used anyway. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jens Lehmann committed
Jan 23, 2010 at 17:37 UTC
4d34477f4c5dbebc55aa1362fd705440590a85f1
1 file changed
+6
-4
diff-lib.c
+6
-4
@@ -179,6 +179,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
179
}
180
changed = ce_match_stat(ce, &st, ce_option);
181
if (S_ISGITLINK(ce->ce_mode)
182
+ && !DIFF_OPT_TST(&revs->diffopt, IGNORE_SUBMODULES)
183
&& (!changed || (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
184
&& is_submodule_modified(ce->name)) {
185
changed = 1;
@@ -220,7 +221,7 @@ static int get_stat_data(struct cache_entry *ce,
221
const unsigned char **sha1p,
222
unsigned int *modep,
223
int cached, int match_missing,
223
- unsigned *dirty_submodule, int output_format)
224
+ unsigned *dirty_submodule, struct diff_options *diffopt)
225
{
226
const unsigned char *sha1 = ce->sha1;
227
unsigned int mode = ce->ce_mode;
@@ -241,7 +242,8 @@ static int get_stat_data(struct cache_entry *ce,
242
}
243
changed = ce_match_stat(ce, &st, 0);
244
if (S_ISGITLINK(ce->ce_mode)
244
- && (!changed || (output_format & DIFF_FORMAT_PATCH))
245
+ && !DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES)
246
+ && (!changed || (diffopt->output_format & DIFF_FORMAT_PATCH))
247
&& is_submodule_modified(ce->name)) {
248
changed = 1;
249
*dirty_submodule = 1;
@@ -270,7 +272,7 @@ static void show_new_file(struct rev_info *revs,
272
* the working copy.
273
*/
274
if (get_stat_data(new, &sha1, &mode, cached, match_missing,
273
- &dirty_submodule, revs->diffopt.output_format) < 0)
275
+ &dirty_submodule, &revs->diffopt) < 0)
276
return;
277
278
diff_index_show_file(revs, "+", new, sha1, mode, dirty_submodule);
@@ -287,7 +289,7 @@ static int show_modified(struct rev_info *revs,
289
unsigned dirty_submodule = 0;
290
291
if (get_stat_data(new, &sha1, &mode, cached, match_missing,
290
- &dirty_submodule, revs->diffopt.output_format) < 0) {
292
+ &dirty_submodule, &revs->diffopt) < 0) {
293
if (report_missing)
294
diff_index_show_file(revs, "-", old,
295
old->sha1, old->ce_mode, 0);