Skip to content

Commit 9cc2590

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6258f68 commit 9cc2590

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

t/t1305-config-include.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,44 @@ test_expect_success 'include cycles are detected' '
357357
grep "exceeded maximum include depth" stderr
358358
'
359359

360+
test_expect_success 'onbranch with unborn branch' '
361+
test_when_finished "rm -rf repo" &&
362+
git init repo &&
363+
(
364+
cd repo &&
365+
git config set includeIf.onbranch:"*".path config.inc &&
366+
git config set -f .git/config.inc foo.bar baz &&
367+
git config get foo.bar
368+
)
369+
'
370+
371+
test_expect_success 'onbranch with detached HEAD' '
372+
test_when_finished "rm -rf repo" &&
373+
git init repo &&
374+
(
375+
cd repo &&
376+
git config set "includeIf.onbranch:*.path" config.inc &&
377+
git config set -f .git/config.inc foo.bar baz &&
378+
test_commit initial &&
379+
git switch --detach HEAD &&
380+
test_must_fail git config get foo.bar
381+
)
382+
'
383+
384+
test_expect_success 'onbranch without repository' '
385+
test_when_finished "rm -f .gitconfig config.inc" &&
386+
git config set -f .gitconfig "includeIf.onbranch:**.path" config.inc &&
387+
git config set -f config.inc foo.bar baz &&
388+
git config get foo.bar &&
389+
test_must_fail nongit git config get foo.bar
390+
'
391+
392+
test_expect_failure 'onbranch without repository but explicit nonexistent Git directory' '
393+
test_when_finished "rm -f .gitconfig config.inc" &&
394+
git config set -f .gitconfig "includeIf.onbranch:**.path" config.inc &&
395+
git config set -f config.inc foo.bar baz &&
396+
git config get foo.bar &&
397+
test_must_fail nongit git --git-dir=nonexistent config get foo.bar
398+
'
399+
360400
test_done

0 commit comments

Comments
 (0)