1#!/bin/sh23test_description='Test submodule--helper is-active45This test verifies that `git submodue--helper is-active` correclty identifies6submodules which are "active" and interesting to the user.7'89. ./test-lib.sh1011test_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'2021test_expect_success 'is-active works with urls' '22git -C super submodule--helper is-active sub1 &&23git -C super submodule--helper is-active sub2 &&2425git -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 sub129'3031test_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" &&3435git -C super config --bool submodule.sub1.active "false" &&36test_must_fail git -C super submodule--helper is-active sub1 &&3738git -C super config --bool submodule.sub1.active "true" &&39git -C super config --unset submodule.sub1.URL &&40git -C super submodule--helper is-active sub141'4243test_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" &&4647git -C super config --add submodule.active "." &&48git -C super config --unset submodule.sub1.URL &&4950git -C super submodule--helper is-active sub1 &&51git -C super submodule--helper is-active sub252'5354test_expect_success 'is-active correctly works with paths that are not submodules' '55test_when_finished "git -C super config --unset-all submodule.active" &&5657test_must_fail git -C super submodule--helper is-active not-a-submodule &&5859git -C super config --add submodule.active "." &&60test_must_fail git -C super submodule--helper is-active not-a-submodule61'6263test_expect_success 'is-active works with exclusions in submodule.active config' '64test_when_finished "git -C super config --unset-all submodule.active" &&6566git -C super config --add submodule.active "." &&67git -C super config --add submodule.active ":(exclude)sub1" &&6869test_must_fail git -C super submodule--helper is-active sub1 &&70git -C super submodule--helper is-active sub271'7273test_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" &&7778git -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" &&8182test_must_fail git -C super submodule--helper is-active sub1 &&83git -C super submodule--helper is-active sub284'8586test_done