Skip to content

Commit

Permalink
t1305: exercise edge cases of "onbranch" includes
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pks-t authored and gitster committed Sep 24, 2024
1 parent 6258f68 commit 9cc2590
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions t/t1305-config-include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9cc2590

Please sign in to comment.