Skip to content

Commit 23b4c7b

Browse files
jlehmanngitster
authored andcommitted
checkout: Use submodule.*.ignore settings from .git/config and .gitmodules
For "git status" and the diff family the submodule.*.ignore settings from .git/config and .gitmodules can be used to override the default set via diff.ignoreSubmodules on a per-submodule basis. Let's do this consistently and teach checkout to use these settings too. Signed-off-by: Jens Lehmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 62ed009 commit 23b4c7b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

builtin/checkout.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
608608
handle_ignore_submodules_arg(&opts->diff_options, value);
609609
return 0;
610610
}
611+
612+
if (!prefixcmp(var, "submodule."))
613+
return parse_submodule_config_option(var, value);
614+
611615
return git_xmerge_config(var, value, NULL);
612616
}
613617

@@ -689,6 +693,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
689693
memset(&opts, 0, sizeof(opts));
690694
memset(&new, 0, sizeof(new));
691695

696+
gitmodules_config();
692697
git_config(git_checkout_config, &opts);
693698

694699
opts.track = BRANCH_TRACK_UNSPECIFIED;

t/t2013-checkout-submodule.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,20 @@ test_expect_success '"checkout <submodule>" honors diff.ignoreSubmodules' '
4646
! test -s actual
4747
'
4848

49+
test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitmodules' '
50+
git config diff.ignoreSubmodules none &&
51+
git config -f .gitmodules submodule.submodule.path submodule &&
52+
git config -f .gitmodules submodule.submodule.ignore untracked &&
53+
git checkout HEAD >actual 2>&1 &&
54+
! test -s actual
55+
'
56+
57+
test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/config' '
58+
git config -f .gitmodules submodule.submodule.ignore none &&
59+
git config submodule.submodule.path submodule &&
60+
git config submodule.submodule.ignore all &&
61+
git checkout HEAD >actual 2>&1 &&
62+
! test -s actual
63+
'
64+
4965
test_done

0 commit comments

Comments
 (0)