The eighth batch
[git.git] / t / t2013-checkout-submodule.sh
blob3c1d663d948490901fb3de330b35ae0227730158
1 #!/bin/sh
3 test_description='checkout can handle submodules'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-submodule-update.sh
9 test_expect_success 'setup' '
10 mkdir submodule &&
11 (cd submodule &&
12 git init &&
13 test_commit first) &&
14 git add submodule &&
15 test_tick &&
16 git commit -m superproject &&
17 (cd submodule &&
18 test_commit second) &&
19 git add submodule &&
20 test_tick &&
21 git commit -m updated.superproject
24 test_expect_success '"reset <submodule>" updates the index' '
25 git update-index --refresh &&
26 git diff-files --quiet &&
27 git diff-index --quiet --cached HEAD &&
28 git reset HEAD^ submodule &&
29 test_must_fail git diff-files --quiet &&
30 git reset submodule &&
31 git diff-files --quiet
34 test_expect_success '"checkout <submodule>" updates the index only' '
35 git update-index --refresh &&
36 git diff-files --quiet &&
37 git diff-index --quiet --cached HEAD &&
38 git checkout HEAD^ submodule &&
39 test_must_fail git diff-files --quiet &&
40 git checkout HEAD submodule &&
41 git diff-files --quiet
44 test_expect_success '"checkout <submodule>" honors diff.ignoreSubmodules' '
45 git config diff.ignoreSubmodules dirty &&
46 echo x> submodule/untracked &&
47 git checkout HEAD >actual 2>&1 &&
48 test_must_be_empty actual
51 test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitmodules' '
52 git config diff.ignoreSubmodules none &&
53 git config -f .gitmodules submodule.submodule.path submodule &&
54 git config -f .gitmodules submodule.submodule.ignore untracked &&
55 git checkout HEAD >actual 2>&1 &&
56 test_must_be_empty actual
59 test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/config' '
60 git config -f .gitmodules submodule.submodule.ignore none &&
61 git config submodule.submodule.path submodule &&
62 git config submodule.submodule.ignore all &&
63 git checkout HEAD >actual 2>&1 &&
64 test_must_be_empty actual
67 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
68 test_submodule_switch_recursing_with_args "checkout"
70 test_submodule_forced_switch_recursing_with_args "checkout -f"
72 test_submodule_switch "checkout"
74 test_submodule_forced_switch "checkout -f"
76 test_done