18
18
#include "xdiff-interface.h"
19
19
#include "ll-merge.h"
20
20
#include "resolve-undo.h"
21
+ #include "submodule.h"
21
22
22
23
static const char * const checkout_usage [] = {
23
24
"git checkout [options] <branch>" ,
@@ -40,6 +41,7 @@ struct checkout_opts {
40
41
const char * new_orphan_branch ;
41
42
int new_branch_log ;
42
43
enum branch_track track ;
44
+ struct diff_options diff_options ;
43
45
};
44
46
45
47
static int post_checkout_hook (struct commit * old , struct commit * new ,
@@ -282,11 +284,12 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
282
284
return errs ;
283
285
}
284
286
285
- static void show_local_changes (struct object * head )
287
+ static void show_local_changes (struct object * head , struct diff_options * opts )
286
288
{
287
289
struct rev_info rev ;
288
290
/* I think we want full paths, even if we're in a subdirectory. */
289
291
init_revisions (& rev , NULL );
292
+ rev .diffopt .flags = opts -> flags ;
290
293
rev .diffopt .output_format |= DIFF_FORMAT_NAME_STATUS ;
291
294
if (diff_setup_done (& rev .diffopt ) < 0 )
292
295
die ("diff_setup_done failed" );
@@ -470,7 +473,7 @@ static int merge_working_tree(struct checkout_opts *opts,
470
473
die ("unable to write new index file" );
471
474
472
475
if (!opts -> force && !opts -> quiet )
473
- show_local_changes (& new -> commit -> object );
476
+ show_local_changes (& new -> commit -> object , & opts -> diff_options );
474
477
475
478
return 0 ;
476
479
}
@@ -618,7 +621,16 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
618
621
619
622
static int git_checkout_config (const char * var , const char * value , void * cb )
620
623
{
621
- return git_xmerge_config (var , value , cb );
624
+ if (!strcmp (var , "diff.ignoresubmodules" )) {
625
+ struct checkout_opts * opts = cb ;
626
+ handle_ignore_submodules_arg (& opts -> diff_options , value );
627
+ return 0 ;
628
+ }
629
+
630
+ if (!prefixcmp (var , "submodule." ))
631
+ return parse_submodule_config_option (var , value );
632
+
633
+ return git_xmerge_config (var , value , NULL );
622
634
}
623
635
624
636
static int interactive_checkout (const char * revision , const char * * pathspec ,
@@ -702,7 +714,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
702
714
memset (& opts , 0 , sizeof (opts ));
703
715
memset (& new , 0 , sizeof (new ));
704
716
705
- git_config (git_checkout_config , NULL );
717
+ gitmodules_config ();
718
+ git_config (git_checkout_config , & opts );
706
719
707
720
opts .track = BRANCH_TRACK_UNSPECIFIED ;
708
721
0 commit comments