Git 2.33.8
[git.git] / t / t7413-submodule-is-active.sh
blobc8b5ac2928f5a92a8a5c975b59a1ca7d3cf775a1
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 config --global protocol.file.allow always &&
13 git init sub &&
14 test_commit -C sub initial &&
15 git init super &&
16 test_commit -C super initial &&
17 git -C super submodule add ../sub sub1 &&
18 git -C super submodule add ../sub sub2 &&
20 # Remove submodule.<name>.active entries in order to test in an
21 # environment where only URLs are present in the conifg
22 git -C super config --unset submodule.sub1.active &&
23 git -C super config --unset submodule.sub2.active &&
25 git -C super commit -a -m "add 2 submodules at sub{1,2}"
28 test_expect_success 'is-active works with urls' '
29 git -C super submodule--helper is-active sub1 &&
30 git -C super submodule--helper is-active sub2 &&
32 git -C super config --unset submodule.sub1.URL &&
33 test_must_fail git -C super submodule--helper is-active sub1 &&
34 git -C super config submodule.sub1.URL ../sub &&
35 git -C super submodule--helper is-active sub1
38 test_expect_success 'is-active works with submodule.<name>.active config' '
39 test_when_finished "git -C super config --unset submodule.sub1.active" &&
40 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
42 git -C super config --bool submodule.sub1.active "false" &&
43 test_must_fail git -C super submodule--helper is-active sub1 &&
45 git -C super config --bool submodule.sub1.active "true" &&
46 git -C super config --unset submodule.sub1.URL &&
47 git -C super submodule--helper is-active sub1
50 test_expect_success 'is-active works with basic submodule.active config' '
51 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
52 test_when_finished "git -C super config --unset-all submodule.active" &&
54 git -C super config --add submodule.active "." &&
55 git -C super config --unset submodule.sub1.URL &&
57 git -C super submodule--helper is-active sub1 &&
58 git -C super submodule--helper is-active sub2
61 test_expect_success 'is-active correctly works with paths that are not submodules' '
62 test_when_finished "git -C super config --unset-all submodule.active" &&
64 test_must_fail git -C super submodule--helper is-active not-a-submodule &&
66 git -C super config --add submodule.active "." &&
67 test_must_fail git -C super submodule--helper is-active not-a-submodule
70 test_expect_success 'is-active works with exclusions in submodule.active config' '
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 --add submodule.active ":(exclude)sub1" &&
76 test_must_fail git -C super submodule--helper is-active sub1 &&
77 git -C super submodule--helper is-active sub2
80 test_expect_success 'is-active with submodule.active and submodule.<name>.active' '
81 test_when_finished "git -C super config --unset-all submodule.active" &&
82 test_when_finished "git -C super config --unset submodule.sub1.active" &&
83 test_when_finished "git -C super config --unset submodule.sub2.active" &&
85 git -C super config --add submodule.active "sub1" &&
86 git -C super config --bool submodule.sub1.active "false" &&
87 git -C super config --bool submodule.sub2.active "true" &&
89 test_must_fail git -C super submodule--helper is-active sub1 &&
90 git -C super submodule--helper is-active sub2
93 test_expect_success 'is-active, submodule.active and submodule add' '
94 test_when_finished "rm -rf super2" &&
95 git init super2 &&
96 test_commit -C super2 initial &&
97 git -C super2 config --add submodule.active "sub*" &&
99 # submodule add should only add submodule.<name>.active
100 # to the config if not matched by the pathspec
101 git -C super2 submodule add ../sub sub1 &&
102 test_must_fail git -C super2 config --get submodule.sub1.active &&
104 git -C super2 submodule add ../sub mod &&
105 git -C super2 config --get submodule.mod.active
108 test_done