Subject: [PATCH 8/9] t: move nested gitdir tests to proper location

From: Adrian Ratiu <[email-masked]>
Date: Sun, 17 Aug 2025 00:36:41 +0300

Now that we are encoding gitdir paths, these tests are not handling
pathological cases anymore, because nested git dirs shouldn't cause
conflicts, so move them from t7450-bad-git-dotfiles.sh to a more
appropriate location where we test mixed gitdir path & encoding use.

Signed-off-by: Adrian Ratiu <[email-masked]>
---
 t/t7425-submodule-mixed-gitdir-paths.sh | 54 ++++++++++++++++++++++++
 t/t7450-bad-git-dotfiles.sh             | 56 -------------------------
 2 files changed, 54 insertions(+), 56 deletions(-)

diff --git a/t/t7425-submodule-mixed-gitdir-paths.sh b/t/t7425-submodule-mixed-gitdir-paths.sh
index 801e90522a..902b2560ca 100755
--- a/t/t7425-submodule-mixed-gitdir-paths.sh
+++ b/t/t7425-submodule-mixed-gitdir-paths.sh
@@ -3,6 +3,7 @@
 test_description='submodules handle mixed legacy and new (encoded) style gitdir paths'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-verify-submodule-gitdir-path.sh
 
 test_expect_success 'setup: allow file protocol' '
 	git config --global protocol.file.allow always
@@ -98,4 +99,57 @@ test_expect_success 'fetch mixed submodule changes and verify updates' '
 	)
 '
 
+test_expect_success 'setup submodules with nested git dirs' '
+	git init nested &&
+	test_commit -C nested nested &&
+	(
+		cd nested &&
+		cat >.gitmodules <<-EOF &&
+		[submodule "hippo"]
+			url = .
+			path = thing1
+		[submodule "hippo/hooks"]
+			url = .
+			path = thing2
+		EOF
+		git clone . thing1 &&
+		git clone . thing2 &&
+		git add .gitmodules thing1 thing2 &&
+		test_tick &&
+		git commit -m nested
+	)
+'
+
+test_expect_success 'git dirs of sibling submodules must not be nested' '
+	git clone --recurse-submodules nested clone_nested &&
+	verify_submodule_gitdir_path clone_nested hippo submodules/hippo &&
+	verify_submodule_gitdir_path clone_nested hippo/hooks submodules/hippo%2fhooks
+'
+
+test_expect_success 'submodule git dir nesting detection must work with parallel cloning' '
+	git clone --recurse-submodules --jobs=2 nested clone_parallel &&
+	verify_submodule_gitdir_path clone_nested hippo submodules/hippo &&
+	verify_submodule_gitdir_path clone_nested hippo/hooks submodules/hippo%2fhooks
+'
+
+test_expect_success 'checkout -f --recurse-submodules must corectly handle nested gitdirs' '
+	git clone nested clone_recursive_checkout &&
+	(
+		cd clone_recursive_checkout &&
+
+		git submodule init &&
+		git submodule update thing1 thing2 &&
+
+		# simulate a malicious nested alternate which git should not follow
+		mkdir -p .git/submodules/hippo/hooks/refs &&
+		mkdir -p .git/submodules/hippo/hooks/objects/info &&
+		echo "../../../../objects" >.git/submodules/hippo/hooks/objects/info/alternates &&
+		echo "ref: refs/heads/master" >.git/submodules/hippo/hooks/HEAD &&
+
+		git checkout -f --recurse-submodules HEAD
+	) &&
+	verify_submodule_gitdir_path clone_nested hippo submodules/hippo &&
+	verify_submodule_gitdir_path clone_nested hippo/hooks submodules/hippo%2fhooks
+'
+
 test_done
diff --git a/t/t7450-bad-git-dotfiles.sh b/t/t7450-bad-git-dotfiles.sh
index 27254300f8..18624fabc4 100755
--- a/t/t7450-bad-git-dotfiles.sh
+++ b/t/t7450-bad-git-dotfiles.sh
@@ -15,7 +15,6 @@ Such as:
 
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-pack.sh
-. "$TEST_DIRECTORY"/lib-verify-submodule-gitdir-path.sh
 
 test_expect_success 'setup' '
 	git config --global protocol.file.allow always
@@ -320,61 +319,6 @@ test_expect_success WINDOWS 'prevent git~1 squatting on Windows' '
 	fi
 '
 
-# TODO: move these nested gitdir tests to another location in a later commit because
-# they are not pathological cases anymore: by encoding the gitdir paths do not conflict.
-test_expect_success 'setup submodules with nested git dirs' '
-	git init nested &&
-	test_commit -C nested nested &&
-	(
-		cd nested &&
-		cat >.gitmodules <<-EOF &&
-		[submodule "hippo"]
-			url = .
-			path = thing1
-		[submodule "hippo/hooks"]
-			url = .
-			path = thing2
-		EOF
-		git clone . thing1 &&
-		git clone . thing2 &&
-		git add .gitmodules thing1 thing2 &&
-		test_tick &&
-		git commit -m nested
-	)
-'
-
-test_expect_success 'git dirs of sibling submodules must not be nested' '
-	git clone --recurse-submodules nested clone_nested &&
-	verify_submodule_gitdir_path clone_nested hippo submodules/hippo &&
-	verify_submodule_gitdir_path clone_nested hippo/hooks submodules/hippo%2fhooks
-'
-
-test_expect_success 'submodule git dir nesting detection must work with parallel cloning' '
-	git clone --recurse-submodules --jobs=2 nested clone_parallel &&
-	verify_submodule_gitdir_path clone_nested hippo submodules/hippo &&
-	verify_submodule_gitdir_path clone_nested hippo/hooks submodules/hippo%2fhooks
-'
-
-test_expect_success 'checkout -f --recurse-submodules must corectly handle nested gitdirs' '
-	git clone nested clone_recursive_checkout &&
-	(
-		cd clone_recursive_checkout &&
-
-		git submodule init &&
-		git submodule update thing1 thing2 &&
-
-		# simulate a malicious nested alternate which git should not follow
-		mkdir -p .git/submodules/hippo/hooks/refs &&
-		mkdir -p .git/submodules/hippo/hooks/objects/info &&
-		echo "../../../../objects" >.git/submodules/hippo/hooks/objects/info/alternates &&
-		echo "ref: refs/heads/master" >.git/submodules/hippo/hooks/HEAD &&
-
-		git checkout -f --recurse-submodules HEAD
-	) &&
-	verify_submodule_gitdir_path clone_nested hippo submodules/hippo &&
-	verify_submodule_gitdir_path clone_nested hippo/hooks submodules/hippo%2fhooks
-'
-
 test_expect_success SYMLINKS,!WINDOWS,!MINGW 'submodule must not checkout into different directory' '
 	test_when_finished "rm -rf sub repo bad-clone" &&
 
-- 
2.50.1.679.gbf363a8fbb.dirty