1818#include "xdiff-interface.h"
1919#include "ll-merge.h"
2020#include "resolve-undo.h"
21+ #include "submodule.h"
2122
2223static const char * const checkout_usage [] = {
2324 "git checkout [options] <branch>" ,
@@ -40,6 +41,7 @@ struct checkout_opts {
4041 const char * new_orphan_branch ;
4142 int new_branch_log ;
4243 enum branch_track track ;
44+ struct diff_options diff_options ;
4345};
4446
4547static 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,
282284 return errs ;
283285}
284286
285- static void show_local_changes (struct object * head )
287+ static void show_local_changes (struct object * head , struct diff_options * opts )
286288{
287289 struct rev_info rev ;
288290 /* I think we want full paths, even if we're in a subdirectory. */
289291 init_revisions (& rev , NULL );
292+ rev .diffopt .flags = opts -> flags ;
290293 rev .diffopt .output_format |= DIFF_FORMAT_NAME_STATUS ;
291294 if (diff_setup_done (& rev .diffopt ) < 0 )
292295 die ("diff_setup_done failed" );
@@ -470,7 +473,7 @@ static int merge_working_tree(struct checkout_opts *opts,
470473 die ("unable to write new index file" );
471474
472475 if (!opts -> force && !opts -> quiet )
473- show_local_changes (& new -> commit -> object );
476+ show_local_changes (& new -> commit -> object , & opts -> diff_options );
474477
475478 return 0 ;
476479}
@@ -618,7 +621,16 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
618621
619622static int git_checkout_config (const char * var , const char * value , void * cb )
620623{
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 );
622634}
623635
624636static int interactive_checkout (const char * revision , const char * * pathspec ,
@@ -702,7 +714,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
702714 memset (& opts , 0 , sizeof (opts ));
703715 memset (& new , 0 , sizeof (new ));
704716
705- git_config (git_checkout_config , NULL );
717+ gitmodules_config ();
718+ git_config (git_checkout_config , & opts );
706719
707720 opts .track = BRANCH_TRACK_UNSPECIFIED ;
708721
0 commit comments