tests: don't assume a .git/info for .git/info/grafts
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Jun 3, 2022 at 13:15 UTC
93e02b6e1e845f5178017c0bac4f18077b331499
8 files changed
+14
-2
t/annotate-tests.sh
+2
-1
@@ -149,7 +149,7 @@ test_expect_success 'blame evil merge' '
149
150
test_expect_success 'blame huge graft' '
151
test_when_finished "git checkout branch2" &&
152
- test_when_finished "rm -f .git/info/grafts" &&
152
+ test_when_finished "rm -rf .git/info" &&
153
graft= &&
154
for i in 0 1 2
155
do
@@ -164,6 +164,7 @@ test_expect_success 'blame huge graft' '
164
graft="$graft$commit " || return 1
165
done
166
done &&
167
+ mkdir .git/info &&
168
printf "%s " $graft >.git/info/grafts &&
169
check_count -h 00 01 1 10 1
170
'
t/t2400-worktree-add.sh
+4
@@ -5,6 +5,7 @@ test_description='test git worktree add'
5
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8
+TEST_CREATE_REPO_NO_TEMPLATE=1
9
. ./test-lib.sh
10
11
. "$TEST_DIRECTORY"/lib-rebase.sh
@@ -229,6 +230,7 @@ test_expect_success 'checkout with grafts' '
230
SHA1=$(git rev-parse HEAD) &&
231
test_commit def &&
232
test_commit xyz &&
233
+ mkdir .git/info &&
234
echo "$(git rev-parse HEAD) $SHA1" >.git/info/grafts &&
235
cat >expected <<-\EOF &&
236
xyz
@@ -559,6 +561,8 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' '
561
'
562
563
post_checkout_hook () {
564
+ test_when_finished "rm -rf .git/hooks" &&
565
+ mkdir .git/hooks &&
566
test_hook -C "$1" post-checkout <<-\EOF
567
{
568
echo $*
t/t5318-commit-graph.sh
+2
-1
@@ -361,13 +361,14 @@ test_expect_success 'replace-objects invalidates commit-graph' '
361
test_expect_success 'commit grafts invalidate commit-graph' '
362
cd "$TRASH_DIRECTORY" &&
363
test_when_finished rm -rf graft &&
364
- git clone full graft &&
364
+ git clone --template= full graft &&
365
(
366
cd graft &&
367
git commit-graph write --reachable &&
368
test_path_is_file .git/objects/info/commit-graph &&
369
H1=$(git rev-parse --verify HEAD~1) &&
370
H3=$(git rev-parse --verify HEAD~3) &&
371
+ mkdir .git/info &&
372
echo "$H1 $H3" >.git/info/grafts &&
373
git -c core.commitGraph=false log >expect &&
374
git -c core.commitGraph=true log >actual &&
t/t6001-rev-list-graft.sh
+1
@@ -99,6 +99,7 @@ do
99
"
100
101
test_expect_success 'with grafts' "
102
+ mkdir -p .git/info &&
103
echo '$B0 $A2' >.git/info/grafts &&
104
check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0
105
"
t/t6101-rev-parse-parents.sh
+2
@@ -8,6 +8,7 @@ test_description='Test git rev-parse with different parent options'
8
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
11
+TEST_CREATE_REPO_NO_TEMPLATE=1
12
. ./test-lib.sh
13
14
test_cmp_rev_output () {
@@ -25,6 +26,7 @@ test_expect_success 'setup' '
26
git merge -m next --allow-unrelated-histories start2 &&
27
test_commit final &&
28
29
+ mkdir .git/info &&
30
test_seq 40 |
31
while read i
32
do
t/t8001-annotate.sh
+1
@@ -4,6 +4,7 @@ test_description='git annotate'
4
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7
+TEST_CREATE_REPO_NO_TEMPLATE=1
8
. ./test-lib.sh
9
10
PROG='git annotate'
t/t8002-blame.sh
+1
@@ -4,6 +4,7 @@ test_description='git blame'
4
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7
+TEST_CREATE_REPO_NO_TEMPLATE=1
8
. ./test-lib.sh
9
10
PROG='git blame -c'
t/t8012-blame-colors.sh
+1
@@ -4,6 +4,7 @@ test_description='colored git blame'
4
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7
+TEST_CREATE_REPO_NO_TEMPLATE=1
8
. ./test-lib.sh
9
10
PROG='git blame -c'