checkout: respect diff.ignoreSubmodules setting
When 'git checkout' reports uncommitted changes, it also does so for submodules. The default mode is now to look really hard into submodules, not only for different commits, but also for modified files. Since this can be pretty expensive when there are a lot (and large) submodules, there is the diff.ignoreSubmodules option. Let's respect that setting when 'git checkout' reports the uncommitted changes, since it does nothing else than a 'git diff --name-status'. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Aug 25, 2010 at 12:34 UTC
175f6e59f6c74d5f8c80fe3a6678915cc5d35cb6
1 file changed
+12
-4
builtin/checkout.c
+12
-4
@@ -18,6 +18,7 @@
18
#include "xdiff-interface.h"
19
#include "ll-merge.h"
20
#include "resolve-undo.h"
21
+#include "submodule.h"
22
23
static const char * const checkout_usage[] = {
24
"git checkout [options] <branch>",
@@ -36,6 +37,7 @@ struct checkout_opts {
37
const char *new_orphan_branch;
38
int new_branch_log;
39
enum branch_track track;
40
+ struct diff_options diff_options;
41
};
42
43
static int post_checkout_hook(struct commit *old, struct commit *new,
@@ -274,12 +276,13 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
276
return errs;
277
}
278
277
-static void show_local_changes(struct object *head)
279
+static void show_local_changes(struct object *head, struct diff_options *opts)
280
{
281
struct rev_info rev;
282
/* I think we want full paths, even if we're in a subdirectory. */
283
init_revisions(&rev, NULL);
284
rev.abbrev = 0;
285
+ rev.diffopt.flags = opts->flags;
286
rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
287
if (diff_setup_done(&rev.diffopt) < 0)
288
die("diff_setup_done failed");
@@ -456,7 +459,7 @@ static int merge_working_tree(struct checkout_opts *opts,
459
die("unable to write new index file");
460
461
if (!opts->force && !opts->quiet)
459
- show_local_changes(&new->commit->object);
462
+ show_local_changes(&new->commit->object, &opts->diff_options);
463
464
return 0;
465
}
@@ -600,7 +603,12 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
603
604
static int git_checkout_config(const char *var, const char *value, void *cb)
605
{
603
- return git_xmerge_config(var, value, cb);
606
+ if (!strcmp(var, "diff.ignoresubmodules")) {
607
+ struct checkout_opts *opts = cb;
608
+ handle_ignore_submodules_arg(&opts->diff_options, value);
609
+ return 0;
610
+ }
611
+ return git_xmerge_config(var, value, NULL);
612
}
613
614
static int interactive_checkout(const char *revision, const char **pathspec,
@@ -681,7 +689,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
689
memset(&opts, 0, sizeof(opts));
690
memset(&new, 0, sizeof(new));
691
684
- git_config(git_checkout_config, NULL);
692
+ git_config(git_checkout_config, &opts);
693
694
opts.track = BRANCH_TRACK_UNSPECIFIED;
695