[Patch 3/3] t1305: add tests for includeIf:worktree.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Randall S. Becker" <rsbecker@xxxxxxxxxxxxx>

The tests are a subset of those for gitdir:, taking into account that
the worktree: form does not support the trailing / at this time in
pattern matches. Some resets of the .git/config file are done to restrict
the set of includeIf paths being evaluated that conflict with prior
subtests.

Signed-off-by: Randall S. Becker <rsbecker@xxxxxxxxxxxxx>
---
 t/t1305-config-include.sh | 81 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index ccbb116c01..fe1ad106c3 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -309,6 +309,69 @@ test_expect_success SYMLINKS 'conditional include, gitdir matching symlink, icas
 	)
 '
 
+test_expect_success 'conditional worktree include, unanchored' '
+	(
+		cd foo &&
+		# Must add a commit for worktree add
+		git commit --allow-empty --allow-empty-message &&
+		sed -i "/includeIf/,\$d" .git/config &&
+		git worktree add ../foo.wt &&
+		echo "[includeIf \"worktree:foo.wt\"]path=bar" >>.git/config &&
+		echo "[test]one=1" >.git/bar &&
+		cd ../foo.wt &&
+		echo 1 >expect &&
+		git config test.one >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'conditional worktree include, $HOME expansion' '
+	(
+		cd foo &&
+		echo "[includeIf \"worktree:~/foo.wt\"]path=bar2" >>.git/config &&
+		echo "[test]two=2" >.git/bar2 &&
+		cd ../foo.wt &&
+		echo 2 >expect &&
+		git config test.two >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'conditional worktree include, full pattern' '
+	(
+		cd foo &&
+		echo "[includeIf \"worktree:**/foo.wt\"]path=bar3" >>.git/config &&
+		echo "[test]three=3" >.git/bar3 &&
+		cd ../foo.wt &&
+		echo 3 >expect &&
+		git config test.three >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'conditional worktree include, relative path' '
+	echo "[includeIf \"worktree:./foo.wt\"]path=bar4" >>.gitconfig &&
+	echo "[test]four=4" >bar4 &&
+	(
+		cd foo.wt &&
+		echo 4 >expect &&
+		git config test.four >actual &&
+		test_cmp expect actual
+	)
+'
+
+test_expect_success 'conditional worktree include, both unanchored, icase' '
+	(
+		cd foo &&
+		echo "[includeIf \"worktree/i:FOO.WT\"]path=bar5" >>.git/config &&
+		echo "[test]five=5" >.git/bar5 &&
+		cd ../foo.wt &&
+		echo 5 >expect &&
+		git config test.five >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_expect_success 'conditional include, onbranch' '
 	echo "[includeIf \"onbranch:foo-branch\"]path=bar9" >>.git/config &&
 	echo "[test]nine=9" >.git/bar9 &&
@@ -348,6 +411,24 @@ test_expect_success 'conditional include, onbranch, implicit /** for /' '
 	test_cmp expect actual
 '
 
+test_expect_success 'conditional worktree include, onbranch' '
+	(
+		cd foo &&
+		sed -i "/includeIf/,\$d" .git/config &&
+		echo "[includeIf \"onbranch:foo.wt2\"]path=bar12" >>.git/config &&
+		echo "[test]twelve=12" >.git/bar12
+	) &&
+	(
+		cd foo.wt &&
+		git checkout -b main &&
+		test_must_fail git config test.twelve &&
+		git checkout -b foo.wt2 &&
+		echo 12 >expect &&
+		git config test.twelve >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_expect_success 'include cycles are detected' '
 	git init --bare cycle &&
 	git -C cycle config include.path cycle &&
-- 
2.32.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux