]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t7413-submodule-is-active.sh
9509dc18fde90919fa316fe7aba5d7a5a6a851a9
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.
14 test_expect_success
'setup' '
15 git config --global protocol.file.allow always &&
17 test_commit -C sub initial &&
19 test_commit -C super initial &&
20 git -C super submodule add ../sub sub1 &&
21 git -C super submodule add ../sub sub2 &&
23 # Remove submodule.<name>.active entries in order to test in an
24 # environment where only URLs are present in the config
25 git -C super config --unset submodule.sub1.active &&
26 git -C super config --unset submodule.sub2.active &&
28 git -C super commit -a -m "add 2 submodules at sub{1,2}"
31 test_expect_success
'is-active works with urls' '
32 test-tool -C super submodule is-active sub1 &&
33 test-tool -C super submodule is-active sub2 &&
35 git -C super config --unset submodule.sub1.URL &&
36 test_must_fail test-tool -C super submodule is-active sub1 &&
37 git -C super config submodule.sub1.URL ../sub &&
38 test-tool -C super submodule is-active sub1
41 test_expect_success
'is-active works with submodule.<name>.active config' '
42 test_when_finished "git -C super config --unset submodule.sub1.active" &&
43 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
45 git -C super config --bool submodule.sub1.active "false" &&
46 test_must_fail test-tool -C super submodule is-active sub1 &&
48 git -C super config --bool submodule.sub1.active "true" &&
49 git -C super config --unset submodule.sub1.URL &&
50 test-tool -C super submodule is-active sub1
53 test_expect_success
'is-active handles submodule.active config missing a value' '
54 cp super/.git/config super/.git/config.orig &&
55 test_when_finished mv super/.git/config.orig super/.git/config &&
57 cat >>super/.git/config <<-\EOF &&
62 cat >expect <<-\EOF &&
63 error: missing value for '\''submodule.active'\''
65 test-tool -C super submodule is-active sub1 2>actual &&
66 test_cmp expect actual
69 test_expect_success
'is-active works with basic submodule.active config' '
70 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
71 test_when_finished "git -C super config --unset-all submodule.active" &&
73 git -C super config --add submodule.active "." &&
74 git -C super config --unset submodule.sub1.URL &&
76 test-tool -C super submodule is-active sub1 &&
77 test-tool -C super submodule is-active sub2
80 test_expect_success
'is-active correctly works with paths that are not submodules' '
81 test_when_finished "git -C super config --unset-all submodule.active" &&
83 test_must_fail test-tool -C super submodule is-active not-a-submodule &&
85 git -C super config --add submodule.active "." &&
86 test_must_fail test-tool -C super submodule is-active not-a-submodule
89 test_expect_success
'is-active works with exclusions in submodule.active config' '
90 test_when_finished "git -C super config --unset-all submodule.active" &&
92 git -C super config --add submodule.active "." &&
93 git -C super config --add submodule.active ":(exclude)sub1" &&
95 test_must_fail test-tool -C super submodule is-active sub1 &&
96 test-tool -C super submodule is-active sub2
99 test_expect_success
'is-active with submodule.active and submodule.<name>.active' '
100 test_when_finished "git -C super config --unset-all submodule.active" &&
101 test_when_finished "git -C super config --unset submodule.sub1.active" &&
102 test_when_finished "git -C super config --unset submodule.sub2.active" &&
104 git -C super config --add submodule.active "sub1" &&
105 git -C super config --bool submodule.sub1.active "false" &&
106 git -C super config --bool submodule.sub2.active "true" &&
108 test_must_fail test-tool -C super submodule is-active sub1 &&
109 test-tool -C super submodule is-active sub2
112 test_expect_success
'is-active, submodule.active and submodule add' '
113 test_when_finished "rm -rf super2" &&
115 test_commit -C super2 initial &&
116 git -C super2 config --add submodule.active "sub*" &&
118 # submodule add should only add submodule.<name>.active
119 # to the config if not matched by the pathspec
120 git -C super2 submodule add ../sub sub1 &&
121 test_must_fail git -C super2 config --get submodule.sub1.active &&
123 git -C super2 submodule add ../sub mod &&
124 git -C super2 config --get submodule.mod.active