Subject: [PATCH] t1900: cover repo info path keys in non-default layouts

From: Jialong Wang <[email-masked]>
Date: Thu, 19 Mar 2026 16:59:03 -0400

Extend the path-key coverage in t1900 to exercise layouts where the
reported paths differ from a regular worktree.

Add comparisons against rev-parse for path.git-dir, path.common-dir,
and path.toplevel in a linked worktree and a repository created with
--separate-git-dir. Also cover path.git-dir with --path-format=relative
in the separate-git-dir case, and path.superproject-working-tree with
--path-format=relative in a submodule.

Signed-off-by: Jialong Wang <[email-masked]>
---
 t/t1900-repo.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
index 6605394d1f..3f39d2b9f6 100755
--- a/t/t1900-repo.sh
+++ b/t/t1900-repo.sh
@@ -241,6 +241,60 @@ test_expect_success 'path.superproject-working-tree matches rev-parse in submodu
 	test_cmp expect actual
 '
 
+test_expect_success 'path keys match rev-parse in linked worktree' '
+	git init path-linked-main &&
+	echo x >path-linked-main/x &&
+	git -C path-linked-main add x &&
+	git -C path-linked-main commit -m x &&
+	git -C path-linked-main worktree add ../path-linked-worktree &&
+
+	expected_value=$(git -C path-linked-worktree rev-parse --absolute-git-dir) &&
+	echo "path.git-dir=$expected_value" >expect &&
+	git -C path-linked-worktree repo info path.git-dir >actual &&
+	test_cmp expect actual &&
+
+	expected_value=$(git -C path-linked-worktree rev-parse --path-format=absolute --git-common-dir) &&
+	echo "path.common-dir=$expected_value" >expect &&
+	git -C path-linked-worktree repo info path.common-dir >actual &&
+	test_cmp expect actual &&
+
+	expected_value=$(git -C path-linked-worktree rev-parse --show-toplevel) &&
+	echo "path.toplevel=$expected_value" >expect &&
+	git -C path-linked-worktree repo info path.toplevel >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'path keys match rev-parse with --separate-git-dir' '
+	git init --separate-git-dir path-separate.git path-separate-worktree &&
+
+	expected_value=$(git -C path-separate-worktree rev-parse --absolute-git-dir) &&
+	echo "path.git-dir=$expected_value" >expect &&
+	git -C path-separate-worktree repo info path.git-dir >actual &&
+	test_cmp expect actual &&
+
+	expected_value=$(git -C path-separate-worktree rev-parse --path-format=absolute --git-common-dir) &&
+	echo "path.common-dir=$expected_value" >expect &&
+	git -C path-separate-worktree repo info path.common-dir >actual &&
+	test_cmp expect actual &&
+
+	expected_value=$(git -C path-separate-worktree rev-parse --show-toplevel) &&
+	echo "path.toplevel=$expected_value" >expect &&
+	git -C path-separate-worktree repo info path.toplevel >actual &&
+	test_cmp expect actual &&
+
+	expected_value=$(git -C path-separate-worktree rev-parse --path-format=relative --git-dir) &&
+	echo "path.git-dir=$expected_value" >expect &&
+	git -C path-separate-worktree repo info --path-format=relative path.git-dir >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'relative path.superproject-working-tree matches rev-parse in submodule' '
+	expected_value=$(git -C path-superproject-parent/sm rev-parse --path-format=relative --show-superproject-working-tree) &&
+	echo "path.superproject-working-tree=$expected_value" >expect &&
+	git -C path-superproject-parent/sm repo info --path-format=relative path.superproject-working-tree >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'path category returns all path keys' '
 	git init path-category &&
 	>expect &&
-- 
2.51.0