]>
Commit | Line | Data |
---|---|---|
5c2bd8b7 BW |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test submodule--helper is-active | |
4 | ||
64127575 | 5 | This test verifies that `git submodue--helper is-active` correctly identifies |
5c2bd8b7 BW |
6 | submodules which are "active" and interesting to the user. |
7 | ' | |
8 | ||
9 | . ./test-lib.sh | |
10 | ||
11 | test_expect_success 'setup' ' | |
0d3beb71 | 12 | git config --global protocol.file.allow always && |
5c2bd8b7 BW |
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 && | |
1b614c07 BW |
19 | |
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 && | |
24 | ||
5c2bd8b7 BW |
25 | git -C super commit -a -m "add 2 submodules at sub{1,2}" |
26 | ' | |
27 | ||
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 && | |
31 | ||
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 | |
36 | ' | |
37 | ||
a086f921 BW |
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" && | |
41 | ||
42 | git -C super config --bool submodule.sub1.active "false" && | |
43 | test_must_fail git -C super submodule--helper is-active sub1 && | |
44 | ||
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 | |
48 | ' | |
49 | ||
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" && | |
53 | ||
54 | git -C super config --add submodule.active "." && | |
55 | git -C super config --unset submodule.sub1.URL && | |
56 | ||
57 | git -C super submodule--helper is-active sub1 && | |
58 | git -C super submodule--helper is-active sub2 | |
59 | ' | |
60 | ||
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" && | |
63 | ||
64 | test_must_fail git -C super submodule--helper is-active not-a-submodule && | |
65 | ||
66 | git -C super config --add submodule.active "." && | |
67 | test_must_fail git -C super submodule--helper is-active not-a-submodule | |
68 | ' | |
69 | ||
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" && | |
72 | ||
73 | git -C super config --add submodule.active "." && | |
74 | git -C super config --add submodule.active ":(exclude)sub1" && | |
75 | ||
76 | test_must_fail git -C super submodule--helper is-active sub1 && | |
77 | git -C super submodule--helper is-active sub2 | |
78 | ' | |
79 | ||
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" && | |
84 | ||
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" && | |
88 | ||
89 | test_must_fail git -C super submodule--helper is-active sub1 && | |
90 | git -C super submodule--helper is-active sub2 | |
91 | ' | |
92 | ||
1b614c07 BW |
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*" && | |
98 | ||
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 && | |
103 | ||
104 | git -C super2 submodule add ../sub mod && | |
105 | git -C super2 config --get submodule.mod.active | |
106 | ' | |
107 | ||
5c2bd8b7 | 108 | test_done |