]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7413-submodule-is-active.sh
submodule--helper init: set submodule.<name>.active
[thirdparty/git.git] / t / t7413-submodule-is-active.sh
CommitLineData
5c2bd8b7
BW
1#!/bin/sh
2
3test_description='Test submodule--helper is-active
4
5This test verifies that `git submodue--helper is-active` correclty identifies
6submodules which are "active" and interesting to the user.
7'
8
9. ./test-lib.sh
10
11test_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 &&
18 git -C super commit -a -m "add 2 submodules at sub{1,2}"
19'
20
21test_expect_success 'is-active works with urls' '
22 git -C super submodule--helper is-active sub1 &&
23 git -C super submodule--helper is-active sub2 &&
24
25 git -C super config --unset submodule.sub1.URL &&
26 test_must_fail git -C super submodule--helper is-active sub1 &&
27 git -C super config submodule.sub1.URL ../sub &&
28 git -C super submodule--helper is-active sub1
29'
30
a086f921
BW
31test_expect_success 'is-active works with submodule.<name>.active config' '
32 test_when_finished "git -C super config --unset submodule.sub1.active" &&
33 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
34
35 git -C super config --bool submodule.sub1.active "false" &&
36 test_must_fail git -C super submodule--helper is-active sub1 &&
37
38 git -C super config --bool submodule.sub1.active "true" &&
39 git -C super config --unset submodule.sub1.URL &&
40 git -C super submodule--helper is-active sub1
41'
42
43test_expect_success 'is-active works with basic submodule.active config' '
44 test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
45 test_when_finished "git -C super config --unset-all submodule.active" &&
46
47 git -C super config --add submodule.active "." &&
48 git -C super config --unset submodule.sub1.URL &&
49
50 git -C super submodule--helper is-active sub1 &&
51 git -C super submodule--helper is-active sub2
52'
53
54test_expect_success 'is-active correctly works with paths that are not submodules' '
55 test_when_finished "git -C super config --unset-all submodule.active" &&
56
57 test_must_fail git -C super submodule--helper is-active not-a-submodule &&
58
59 git -C super config --add submodule.active "." &&
60 test_must_fail git -C super submodule--helper is-active not-a-submodule
61'
62
63test_expect_success 'is-active works with exclusions in submodule.active config' '
64 test_when_finished "git -C super config --unset-all submodule.active" &&
65
66 git -C super config --add submodule.active "." &&
67 git -C super config --add submodule.active ":(exclude)sub1" &&
68
69 test_must_fail git -C super submodule--helper is-active sub1 &&
70 git -C super submodule--helper is-active sub2
71'
72
73test_expect_success 'is-active with submodule.active and submodule.<name>.active' '
74 test_when_finished "git -C super config --unset-all submodule.active" &&
75 test_when_finished "git -C super config --unset submodule.sub1.active" &&
76 test_when_finished "git -C super config --unset submodule.sub2.active" &&
77
78 git -C super config --add submodule.active "sub1" &&
79 git -C super config --bool submodule.sub1.active "false" &&
80 git -C super config --bool submodule.sub2.active "true" &&
81
82 test_must_fail git -C super submodule--helper is-active sub1 &&
83 git -C super submodule--helper is-active sub2
84'
85
5c2bd8b7 86test_done