1#!/bin/sh
23
test_description='Test submodule--helper is-active
45
This test verifies that `git submodue--helper is-active` correclty identifies
6submodules which are "active" and interesting to the user.
7'
89
. ./test-lib.sh
1011
test_expect_success 'setup' '
12git init sub &&
13test_commit -C sub initial &&
14git init super &&
15test_commit -C super initial &&
16git -C super submodule add ../sub sub1 &&
17git -C super submodule add ../sub sub2 &&
18git -C super commit -a -m "add 2 submodules at sub{1,2}"
19'
2021
test_expect_success 'is-active works with urls' '
22git -C super submodule--helper is-active sub1 &&
23git -C super submodule--helper is-active sub2 &&
2425
git -C super config --unset submodule.sub1.URL &&
26test_must_fail git -C super submodule--helper is-active sub1 &&
27git -C super config submodule.sub1.URL ../sub &&
28git -C super submodule--helper is-active sub1
29'
3031
test_expect_success 'is-active works with submodule.<name>.active config' '
32test_when_finished "git -C super config --unset submodule.sub1.active" &&
33test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
3435
git -C super config --bool submodule.sub1.active "false" &&
36test_must_fail git -C super submodule--helper is-active sub1 &&
3738
git -C super config --bool submodule.sub1.active "true" &&
39git -C super config --unset submodule.sub1.URL &&
40git -C super submodule--helper is-active sub1
41'
4243
test_expect_success 'is-active works with basic submodule.active config' '
44test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
45test_when_finished "git -C super config --unset-all submodule.active" &&
4647
git -C super config --add submodule.active "." &&
48git -C super config --unset submodule.sub1.URL &&
4950
git -C super submodule--helper is-active sub1 &&
51git -C super submodule--helper is-active sub2
52'
5354
test_expect_success 'is-active correctly works with paths that are not submodules' '
55test_when_finished "git -C super config --unset-all submodule.active" &&
5657
test_must_fail git -C super submodule--helper is-active not-a-submodule &&
5859
git -C super config --add submodule.active "." &&
60test_must_fail git -C super submodule--helper is-active not-a-submodule
61'
6263
test_expect_success 'is-active works with exclusions in submodule.active config' '
64test_when_finished "git -C super config --unset-all submodule.active" &&
6566
git -C super config --add submodule.active "." &&
67git -C super config --add submodule.active ":(exclude)sub1" &&
6869
test_must_fail git -C super submodule--helper is-active sub1 &&
70git -C super submodule--helper is-active sub2
71'
7273
test_expect_success 'is-active with submodule.active and submodule.<name>.active' '
74test_when_finished "git -C super config --unset-all submodule.active" &&
75test_when_finished "git -C super config --unset submodule.sub1.active" &&
76test_when_finished "git -C super config --unset submodule.sub2.active" &&
7778
git -C super config --add submodule.active "sub1" &&
79git -C super config --bool submodule.sub1.active "false" &&
80git -C super config --bool submodule.sub2.active "true" &&
8182
test_must_fail git -C super submodule--helper is-active sub1 &&
83git -C super submodule--helper is-active sub2
84'
8586
test_done