Merge branch 'nd/pack-deltify-regression-fix'
[alt-git.git] / t / t7413-submodule-is-active.sh
blobc8e7e983317610b54da89101bea8f7c59a4dcec3
1 #!/bin/sh
3 test_description='Test submodule--helper is-active
5 This test verifies that `git submodue--helper is-active` correctly identifies
6 submodules which are "active" and interesting to the user.
9 . ./test-lib.sh
11 test_expect_success 'setup' '
12 git init sub &&
13 test_commit -C sub initial &&
14 git init super &&
15 test_commit -C super initial &&
16 git -C super submodule add ../sub sub1 &&
17 git -C super submodule add ../sub sub2 &&
19 # Remove submodule.<name>.active entries in order to test in an
20 # environment where only URLs are present in the conifg
21 git -C super config --unset submodule.sub1.active &&
22 git -C super config --unset submodule.sub2.active &&
24 git -C super commit -a -m "add 2 submodules at sub{1,2}"
27 test_expect_success 'is-active works with urls' '
28 git -C super submodule--helper is-active sub1 &&
29 git -C super submodule--helper is-active sub2 &&
31 git -C super config --unset submodule.sub1.URL &&
32 test_must_fail git -C super submodule--helper is-active sub1 &&
33 git -C super config submodule.sub1.URL ../sub &&
34 git -C super submodule--helper is-active sub1
37 test_expect_success 'is-active works with submodule.<name>.active config' '
38 test_when_finished "git -C super config --unset submodule.sub1.active" &&
39 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
41 git -C super config --bool submodule.sub1.active "false" &&
42 test_must_fail git -C super submodule--helper is-active sub1 &&
44 git -C super config --bool submodule.sub1.active "true" &&
45 git -C super config --unset submodule.sub1.URL &&
46 git -C super submodule--helper is-active sub1
49 test_expect_success 'is-active works with basic submodule.active config' '
50 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
51 test_when_finished "git -C super config --unset-all submodule.active" &&
53 git -C super config --add submodule.active "." &&
54 git -C super config --unset submodule.sub1.URL &&
56 git -C super submodule--helper is-active sub1 &&
57 git -C super submodule--helper is-active sub2
60 test_expect_success 'is-active correctly works with paths that are not submodules' '
61 test_when_finished "git -C super config --unset-all submodule.active" &&
63 test_must_fail git -C super submodule--helper is-active not-a-submodule &&
65 git -C super config --add submodule.active "." &&
66 test_must_fail git -C super submodule--helper is-active not-a-submodule
69 test_expect_success 'is-active works with exclusions in submodule.active config' '
70 test_when_finished "git -C super config --unset-all submodule.active" &&
72 git -C super config --add submodule.active "." &&
73 git -C super config --add submodule.active ":(exclude)sub1" &&
75 test_must_fail git -C super submodule--helper is-active sub1 &&
76 git -C super submodule--helper is-active sub2
79 test_expect_success 'is-active with submodule.active and submodule.<name>.active' '
80 test_when_finished "git -C super config --unset-all submodule.active" &&
81 test_when_finished "git -C super config --unset submodule.sub1.active" &&
82 test_when_finished "git -C super config --unset submodule.sub2.active" &&
84 git -C super config --add submodule.active "sub1" &&
85 git -C super config --bool submodule.sub1.active "false" &&
86 git -C super config --bool submodule.sub2.active "true" &&
88 test_must_fail git -C super submodule--helper is-active sub1 &&
89 git -C super submodule--helper is-active sub2
92 test_expect_success 'is-active, submodule.active and submodule add' '
93 test_when_finished "rm -rf super2" &&
94 git init super2 &&
95 test_commit -C super2 initial &&
96 git -C super2 config --add submodule.active "sub*" &&
98 # submodule add should only add submodule.<name>.active
99 # to the config if not matched by the pathspec
100 git -C super2 submodule add ../sub sub1 &&
101 test_must_fail git -C super2 config --get submodule.sub1.active &&
103 git -C super2 submodule add ../sub mod &&
104 git -C super2 config --get submodule.mod.active
107 test_done