git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 6/7] tests: don't assume a .git/info for .git/info/exclude

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 3, 2022, 11:15 UTC
Message-ID
<patch-v2-6.7-29da5a3d431-20220603T110506Z-avarab@gmail.com>
In-Reply-To
<cover-v2-0.7-00000000000-20220603T110506Z-avarab@gmail.com>

Change those tests that assumed that a .git/info directory would be created for them when writing .git/info/exclude to explicitly create the directory by setting "TEST_CREATE_REPO_NO_TEMPLATE=1" before sourcing test-lib.sh, and using the "--template=" argument to "git clone" and "git init".

In the case of ".git/modules/sub1/info" we deviate from the established pattern in this and preceding commits of passing a "--template=" and doing a "mkdir .git/info".

In that case "git checkout" will run the "submodule--helper clone", and both e.g. "git submodule update --init" and "git checkout" do not have a way to pass down options to the eventual "git init" or "git clone". Let's instead assume that the submodule was populated with our default templates, remove them, and then run the "mkdir".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/lib-submodule-update.sh         | 7 +++++--
 t/t0008-ignores.sh                | 2 ++
 t/t3426-rebase-submodule.sh       | 1 +
 t/t7063-status-untracked-cache.sh | 3 ++-
 4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index f7c7df0ca42..03e0abbdb83 100644
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -207,7 +207,7 @@ prolog () {
 # should be updated to an existing commit.
 reset_work_tree_to () {
 	rm -rf submodule_update &&
-	git clone submodule_update_repo submodule_update &&
+	git clone --template= submodule_update_repo submodule_update &&
 	(
 		cd submodule_update &&
 		rm -rf sub1 &&
@@ -902,13 +902,14 @@ test_submodule_switch_recursing_with_args () {
 	'
 	# ... but an ignored file is fine.
 	test_expect_$RESULTOI "$command: added submodule removes an untracked ignored file" '
-		test_when_finished "rm submodule_update/.git/info/exclude" &&
+		test_when_finished "rm -rf submodule_update/.git/info" &&
 		prolog &&
 		reset_work_tree_to_interested no_submodule &&
 		(
 			cd submodule_update &&
 			git branch -t add_sub1 origin/add_sub1 &&
 			: >sub1 &&
+			mkdir .git/info &&
 			echo sub1 >.git/info/exclude &&
 			$command add_sub1 &&
 			test_superproject_content origin/add_sub1 &&
@@ -951,7 +952,9 @@ test_submodule_switch_recursing_with_args () {
 		reset_work_tree_to_interested add_sub1 &&
 		(
 			cd submodule_update &&
+			rm -rf .git/modules/sub1/info &&
 			git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
+			mkdir .git/modules/sub1/info &&
 			echo ignored >.git/modules/sub1/info/exclude &&
 			: >sub1/ignored &&
 			$command replace_sub1_with_file &&
diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
index c3655a0c53e..c70d11bc914 100755
--- a/t/t0008-ignores.sh
+++ b/t/t0008-ignores.sh
@@ -3,6 +3,7 @@
 test_description=check-ignore
 
 TEST_PASSES_SANITIZE_LEAK=true
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 init_vars () {
@@ -225,6 +226,7 @@ test_expect_success 'setup' '
 		!globaltwo
 		globalthree
 	EOF
+	mkdir .git/info &&
 	cat <<-\EOF >.git/info/exclude
 		per-repo
 	EOF
diff --git a/t/t3426-rebase-submodule.sh b/t/t3426-rebase-submodule.sh
index 0ad3a07bf47..7a9f1127a4b 100755
--- a/t/t3426-rebase-submodule.sh
+++ b/t/t3426-rebase-submodule.sh
@@ -35,6 +35,7 @@ git_rebase_interactive () {
 	ls -1pR * >>actual &&
 	test_cmp expect actual &&
 	set_fake_editor &&
+	mkdir .git/info &&
 	echo "fake-editor.sh" >.git/info/exclude &&
 	may_only_be_test_must_fail "$2" &&
 	$2 git rebase -i "$1"
diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh
index 9936cc329ec..f5050b75b29 100755
--- a/t/t7063-status-untracked-cache.sh
+++ b/t/t7063-status-untracked-cache.sh
@@ -86,7 +86,7 @@ test_expect_success 'core.untrackedCache is unset' '
 '
 
 test_expect_success 'setup' '
-	git init worktree &&
+	git init --template= worktree &&
 	cd worktree &&
 	mkdir done dtwo dthree &&
 	touch one two three done/one dtwo/two dthree/three &&
@@ -94,6 +94,7 @@ test_expect_success 'setup' '
 	test-tool chmtime =-300 done dtwo dthree &&
 	test-tool chmtime =-300 . &&
 	git add one two done/one &&
+	mkdir .git/info &&
 	: >.git/info/exclude &&
 	git update-index --untracked-cache &&
 	test_oid_cache <<-EOF
-- 
2.36.1.1119.g5a713b43bd4
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 40 of 44 in “tests + init: don't rely on templates & add --no-template + config”
  1. 00/13 tests + init: don't rely on templates & add --no-template + configÆvar Arnfjörð Bjarmason, Dec 12, 2021
  2. 01/13 t0001: fix gaps in "TEMPLATE DIRECTORY" coverageÆvar Arnfjörð Bjarmason, Dec 12, 2021
  3. 02/13 init: split out template population from create_default_files()Ævar Arnfjörð Bjarmason, Dec 12, 2021
  4. 03/13 init: unconditionally create the "info" directoryÆvar Arnfjörð Bjarmason, Dec 12, 2021
  5. Derrick StoleeDec 20, 2021
  6. Ævar Arnfjörð BjarmasonDec 20, 2021
  7. Derrick StoleeDec 20, 2021
  8. Ævar Arnfjörð BjarmasonDec 20, 2021
  9. Junio C HamanoDec 20, 2021
  10. Ævar Arnfjörð BjarmasonDec 21, 2021
  11. Junio C HamanoDec 21, 2021
  12. Ævar Arnfjörð BjarmasonDec 21, 2021
  13. Junio C HamanoDec 21, 2021
  14. Ævar Arnfjörð BjarmasonDec 24, 2021
  15. Junio C HamanoDec 25, 2021
  16. Ævar Arnfjörð BjarmasonJan 12, 2022
  17. Derrick StoleeJan 18, 2022
  18. Ævar Arnfjörð BjarmasonJan 19, 2022
  19. 04/13 t0008: don't rely on default ".git/info/exclude"Ævar Arnfjörð Bjarmason, Dec 12, 2021
  20. 05/13 init & clone: add a --no-template optionÆvar Arnfjörð Bjarmason, Dec 12, 2021
  21. 06/13 init & clone: add init.templateDir=[bool]Ævar Arnfjörð Bjarmason, Dec 12, 2021
  22. 07/13 test-lib: create test data with "git init --no-template" (almost)Ævar Arnfjörð Bjarmason, Dec 12, 2021
  23. 08/13 tests: don't depend on template-created .git/branchesÆvar Arnfjörð Bjarmason, Dec 12, 2021
  24. 11/13 tests: change "cat && chmod +x" to use "write_hook"Ævar Arnfjörð Bjarmason, Dec 12, 2021
  25. 10/13 test-lib-functions: add and use a "write_hook" wrapperÆvar Arnfjörð Bjarmason, Dec 12, 2021
  26. Eric SunshineDec 13, 2021
  27. Ævar Arnfjörð BjarmasonDec 13, 2021
  28. Eric SunshineDec 13, 2021
  29. Ævar Arnfjörð BjarmasonDec 13, 2021
  30. Eric SunshineDec 13, 2021
  31. 09/13 t5540: don't rely on "hook/post-update.sample"Ævar Arnfjörð Bjarmason, Dec 12, 2021
  32. 12/13 tests: migrate miscellaneous "write_script" to "write_hooks"Ævar Arnfjörð Bjarmason, Dec 12, 2021
  33. 13/13 tests: don't depend on template-created .git/hooksÆvar Arnfjörð Bjarmason, Dec 12, 2021
  34. 0/7 tests: don't depend on "git init" using the templateÆvar Arnfjörð Bjarmason, Jun 3, 2022
  35. 1/7 t0008: don't rely on default ".git/info/exclude"Ævar Arnfjörð Bjarmason, Jun 3, 2022
  36. 2/7 tests: don't depend on template-created .git/branchesÆvar Arnfjörð Bjarmason, Jun 3, 2022
  37. 3/7 tests: don't assume a .git/info for .git/info/graftsÆvar Arnfjörð Bjarmason, Jun 3, 2022
  38. 4/7 tests: don't assume a .git/info for .git/info/attributesÆvar Arnfjörð Bjarmason, Jun 3, 2022
  39. 5/7 tests: don't assume a .git/info for .git/info/refsÆvar Arnfjörð Bjarmason, Jun 3, 2022
  40. 6/7 tests: don't assume a .git/info for .git/info/excludeÆvar Arnfjörð Bjarmason, Jun 3, 2022
  41. 7/7 tests: don't assume a .git/info for .git/info/sparse-checkoutÆvar Arnfjörð Bjarmason, Jun 3, 2022
  42. Junio C HamanoJun 3, 2022
  43. Ævar Arnfjörð BjarmasonJun 4, 2022
  44. Junio C HamanoJun 6, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.