aboutsummaryrefslogtreecommitdiffstats
path: root/t/t1305-config-include.sh
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-09-24 12:05:42 +0200
committerJunio C Hamano <gitster@pobox.com>2024-09-24 09:18:16 -0700
commit9cc2590ab988a357ffe214ecffbe78cfac29da17 (patch)
treed66ae998034aadcbce419ba0114905bba9a72c69 /t/t1305-config-include.sh
parentThe 20th batch (diff)
downloadgit-9cc2590ab988a357ffe214ecffbe78cfac29da17.tar.gz
git-9cc2590ab988a357ffe214ecffbe78cfac29da17.zip
t1305: exercise edge cases of "onbranch" includes
Add a couple more tests for "onbranch" includes for several edge cases. All tests except for the last one pass, so for the most part this change really only aims to nail down behaviour of include conditionals further. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1305-config-include.sh')
-rwxr-xr-xt/t1305-config-include.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index 5cde79ef8c..ad08db7230 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -357,4 +357,44 @@ test_expect_success 'include cycles are detected' '
grep "exceeded maximum include depth" stderr
'
+test_expect_success 'onbranch with unborn branch' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ git config set includeIf.onbranch:"*".path config.inc &&
+ git config set -f .git/config.inc foo.bar baz &&
+ git config get foo.bar
+ )
+'
+
+test_expect_success 'onbranch with detached HEAD' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ git config set "includeIf.onbranch:*.path" config.inc &&
+ git config set -f .git/config.inc foo.bar baz &&
+ test_commit initial &&
+ git switch --detach HEAD &&
+ test_must_fail git config get foo.bar
+ )
+'
+
+test_expect_success 'onbranch without repository' '
+ test_when_finished "rm -f .gitconfig config.inc" &&
+ git config set -f .gitconfig "includeIf.onbranch:**.path" config.inc &&
+ git config set -f config.inc foo.bar baz &&
+ git config get foo.bar &&
+ test_must_fail nongit git config get foo.bar
+'
+
+test_expect_failure 'onbranch without repository but explicit nonexistent Git directory' '
+ test_when_finished "rm -f .gitconfig config.inc" &&
+ git config set -f .gitconfig "includeIf.onbranch:**.path" config.inc &&
+ git config set -f config.inc foo.bar baz &&
+ git config get foo.bar &&
+ test_must_fail nongit git --git-dir=nonexistent config get foo.bar
+'
+
test_done