3 test_description='checkout can handle submodules'
6 . "$TEST_DIRECTORY"/lib-submodule-update.sh
8 test_expect_success 'setup' '
15 git commit -m superproject &&
17 test_commit second) &&
20 git commit -m updated.superproject
23 test_expect_success '"reset <submodule>" updates the index' '
24 git update-index --refresh &&
25 git diff-files --quiet &&
26 git diff-index --quiet --cached HEAD &&
27 git reset HEAD^ submodule &&
28 test_must_fail git diff-files --quiet &&
29 git reset submodule &&
30 git diff-files --quiet
33 test_expect_success '"checkout <submodule>" updates the index only' '
34 git update-index --refresh &&
35 git diff-files --quiet &&
36 git diff-index --quiet --cached HEAD &&
37 git checkout HEAD^ submodule &&
38 test_must_fail git diff-files --quiet &&
39 git checkout HEAD submodule &&
40 git diff-files --quiet
43 test_expect_success '"checkout <submodule>" honors diff.ignoreSubmodules' '
44 git config diff.ignoreSubmodules dirty &&
45 echo x> submodule/untracked &&
46 git checkout HEAD >actual 2>&1 &&
47 test_must_be_empty actual
50 test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitmodules' '
51 git config diff.ignoreSubmodules none &&
52 git config -f .gitmodules submodule.submodule.path submodule &&
53 git config -f .gitmodules submodule.submodule.ignore untracked &&
54 git checkout HEAD >actual 2>&1 &&
55 test_must_be_empty actual
58 test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/config' '
59 git config -f .gitmodules submodule.submodule.ignore none &&
60 git config submodule.submodule.path submodule &&
61 git config submodule.submodule.ignore all &&
62 git checkout HEAD >actual 2>&1 &&
63 test_must_be_empty actual
66 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
67 test_submodule_switch_recursing_with_args "checkout"
69 test_submodule_forced_switch_recursing_with_args "checkout -f"
71 test_submodule_switch "checkout"
73 test_submodule_forced_switch "checkout -f"