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

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

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 3, 2022, 11:15 UTC
Message-ID
<patch-v2-3.7-967762b4670-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/grafts to explicitly create the directory.

Do this using the new "TEST_CREATE_REPO_NO_TEMPLATE" facility, and use "mkdir" instead of "mkdir -p" to assert that we don't have the .git/info already. An exception to this is the "with grafts" test in "t6001-rev-list-graft.sh". There we're modifying our ".git" state in a for-loop, in lieu of refactoring that more extensively let's use "mkdir -p" there.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/annotate-tests.sh          | 3 ++-
 t/t2400-worktree-add.sh      | 4 ++++
 t/t5318-commit-graph.sh      | 3 ++-
 t/t6001-rev-list-graft.sh    | 1 +
 t/t6101-rev-parse-parents.sh | 2 ++
 t/t8001-annotate.sh          | 1 +
 t/t8002-blame.sh             | 1 +
 t/t8012-blame-colors.sh      | 1 +
 8 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index cc01d891504..f1b9a6ce4da 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -153,7 +153,7 @@ test_expect_success 'blame evil merge' '
 
 test_expect_success 'blame huge graft' '
 	test_when_finished "git checkout branch2" &&
-	test_when_finished "rm -f .git/info/grafts" &&
+	test_when_finished "rm -rf .git/info" &&
 	graft= &&
 	for i in 0 1 2
 	do
@@ -168,6 +168,7 @@ test_expect_success 'blame huge graft' '
 			graft="$graft$commit " || return 1
 		done
 	done &&
+	mkdir .git/info &&
 	printf "%s " $graft >.git/info/grafts &&
 	check_count -h 00 01 1 10 1
 '
diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh
index 2f564d533d0..f3242fef6b6 100755
--- a/t/t2400-worktree-add.sh
+++ b/t/t2400-worktree-add.sh
@@ -5,6 +5,7 @@ test_description='test git worktree add'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 . "$TEST_DIRECTORY"/lib-rebase.sh
@@ -229,6 +230,7 @@ test_expect_success 'checkout with grafts' '
 	SHA1=$(git rev-parse HEAD) &&
 	test_commit def &&
 	test_commit xyz &&
+	mkdir .git/info &&
 	echo "$(git rev-parse HEAD) $SHA1" >.git/info/grafts &&
 	cat >expected <<-\EOF &&
 	xyz
@@ -559,6 +561,8 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' '
 '
 
 post_checkout_hook () {
+	test_when_finished "rm -rf .git/hooks" &&
+	mkdir .git/hooks &&
 	test_hook -C "$1" post-checkout <<-\EOF
 	{
 		echo $*
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index fbf0d64578c..be0b5641ffc 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -361,13 +361,14 @@ test_expect_success 'replace-objects invalidates commit-graph' '
 test_expect_success 'commit grafts invalidate commit-graph' '
 	cd "$TRASH_DIRECTORY" &&
 	test_when_finished rm -rf graft &&
-	git clone full graft &&
+	git clone --template= full graft &&
 	(
 		cd graft &&
 		git commit-graph write --reachable &&
 		test_path_is_file .git/objects/info/commit-graph &&
 		H1=$(git rev-parse --verify HEAD~1) &&
 		H3=$(git rev-parse --verify HEAD~3) &&
+		mkdir .git/info &&
 		echo "$H1 $H3" >.git/info/grafts &&
 		git -c core.commitGraph=false log >expect &&
 		git -c core.commitGraph=true log >actual &&
diff --git a/t/t6001-rev-list-graft.sh b/t/t6001-rev-list-graft.sh
index 7294147334a..16635ecc33e 100755
--- a/t/t6001-rev-list-graft.sh
+++ b/t/t6001-rev-list-graft.sh
@@ -99,6 +99,7 @@ do
 	"
 
 	test_expect_success 'with grafts' "
+		mkdir -p .git/info &&
 		echo '$B0 $A2' >.git/info/grafts &&
 		check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0
 	"
diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh
index c571fa51797..5f55ab98d35 100755
--- a/t/t6101-rev-parse-parents.sh
+++ b/t/t6101-rev-parse-parents.sh
@@ -8,6 +8,7 @@ test_description='Test git rev-parse with different parent options'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 test_cmp_rev_output () {
@@ -25,6 +26,7 @@ test_expect_success 'setup' '
 	git merge -m next --allow-unrelated-histories start2 &&
 	test_commit final &&
 
+	mkdir .git/info &&
 	test_seq 40 |
 	while read i
 	do
diff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh
index a536a621b24..d7167f55397 100755
--- a/t/t8001-annotate.sh
+++ b/t/t8001-annotate.sh
@@ -4,6 +4,7 @@ test_description='git annotate'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 PROG='git annotate'
diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh
index ee4fdd8f18d..0147de304b4 100755
--- a/t/t8002-blame.sh
+++ b/t/t8002-blame.sh
@@ -4,6 +4,7 @@ test_description='git blame'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 PROG='git blame -c'
diff --git a/t/t8012-blame-colors.sh b/t/t8012-blame-colors.sh
index 90c75dbb283..c3a5f6d01ff 100755
--- a/t/t8012-blame-colors.sh
+++ b/t/t8012-blame-colors.sh
@@ -4,6 +4,7 @@ test_description='colored git blame'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_CREATE_REPO_NO_TEMPLATE=1
 . ./test-lib.sh
 
 PROG='git blame -c'
-- 
2.36.1.1119.g5a713b43bd4
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 37 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.