Merge branch 'fc/advice-diverged-history'
[git/debian.git] / t / t7413-submodule-is-active.sh
blob7cdc26376490e80274c4f699ddd0b00c25e4d9cd
1 #!/bin/sh
3 test_description='Test with test-tool submodule is-active
5 This test verifies that `test-tool submodule is-active` correctly identifies
6 submodules which are "active" and interesting to the user.
8 This is a unit test of the submodule.c is_submodule_active() function,
9 which is also indirectly tested elsewhere.
12 TEST_PASSES_SANITIZE_LEAK=true
13 . ./test-lib.sh
15 test_expect_success 'setup' '
16 git config --global protocol.file.allow always &&
17 git init sub &&
18 test_commit -C sub initial &&
19 git init super &&
20 test_commit -C super initial &&
21 git -C super submodule add ../sub sub1 &&
22 git -C super submodule add ../sub sub2 &&
24 # Remove submodule.<name>.active entries in order to test in an
25 # environment where only URLs are present in the conifg
26 git -C super config --unset submodule.sub1.active &&
27 git -C super config --unset submodule.sub2.active &&
29 git -C super commit -a -m "add 2 submodules at sub{1,2}"
32 test_expect_success 'is-active works with urls' '
33 test-tool -C super submodule is-active sub1 &&
34 test-tool -C super submodule is-active sub2 &&
36 git -C super config --unset submodule.sub1.URL &&
37 test_must_fail test-tool -C super submodule is-active sub1 &&
38 git -C super config submodule.sub1.URL ../sub &&
39 test-tool -C super submodule is-active sub1
42 test_expect_success 'is-active works with submodule.<name>.active config' '
43 test_when_finished "git -C super config --unset submodule.sub1.active" &&
44 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
46 git -C super config --bool submodule.sub1.active "false" &&
47 test_must_fail test-tool -C super submodule is-active sub1 &&
49 git -C super config --bool submodule.sub1.active "true" &&
50 git -C super config --unset submodule.sub1.URL &&
51 test-tool -C super submodule is-active sub1
54 test_expect_success 'is-active works with basic submodule.active config' '
55 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
56 test_when_finished "git -C super config --unset-all submodule.active" &&
58 git -C super config --add submodule.active "." &&
59 git -C super config --unset submodule.sub1.URL &&
61 test-tool -C super submodule is-active sub1 &&
62 test-tool -C super submodule is-active sub2
65 test_expect_success 'is-active correctly works with paths that are not submodules' '
66 test_when_finished "git -C super config --unset-all submodule.active" &&
68 test_must_fail test-tool -C super submodule is-active not-a-submodule &&
70 git -C super config --add submodule.active "." &&
71 test_must_fail test-tool -C super submodule is-active not-a-submodule
74 test_expect_success 'is-active works with exclusions in submodule.active config' '
75 test_when_finished "git -C super config --unset-all submodule.active" &&
77 git -C super config --add submodule.active "." &&
78 git -C super config --add submodule.active ":(exclude)sub1" &&
80 test_must_fail test-tool -C super submodule is-active sub1 &&
81 test-tool -C super submodule is-active sub2
84 test_expect_success 'is-active with submodule.active and submodule.<name>.active' '
85 test_when_finished "git -C super config --unset-all submodule.active" &&
86 test_when_finished "git -C super config --unset submodule.sub1.active" &&
87 test_when_finished "git -C super config --unset submodule.sub2.active" &&
89 git -C super config --add submodule.active "sub1" &&
90 git -C super config --bool submodule.sub1.active "false" &&
91 git -C super config --bool submodule.sub2.active "true" &&
93 test_must_fail test-tool -C super submodule is-active sub1 &&
94 test-tool -C super submodule is-active sub2
97 test_expect_success 'is-active, submodule.active and submodule add' '
98 test_when_finished "rm -rf super2" &&
99 git init super2 &&
100 test_commit -C super2 initial &&
101 git -C super2 config --add submodule.active "sub*" &&
103 # submodule add should only add submodule.<name>.active
104 # to the config if not matched by the pathspec
105 git -C super2 submodule add ../sub sub1 &&
106 test_must_fail git -C super2 config --get submodule.sub1.active &&
108 git -C super2 submodule add ../sub mod &&
109 git -C super2 config --get submodule.mod.active
112 test_done