Skip to content

Commit 93e02b6

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e942292 commit 93e02b6

8 files changed

+14
-2
lines changed

t/annotate-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ test_expect_success 'blame evil merge' '
149149

150150
test_expect_success 'blame huge graft' '
151151
test_when_finished "git checkout branch2" &&
152-
test_when_finished "rm -f .git/info/grafts" &&
152+
test_when_finished "rm -rf .git/info" &&
153153
graft= &&
154154
for i in 0 1 2
155155
do
@@ -164,6 +164,7 @@ test_expect_success 'blame huge graft' '
164164
graft="$graft$commit " || return 1
165165
done
166166
done &&
167+
mkdir .git/info &&
167168
printf "%s " $graft >.git/info/grafts &&
168169
check_count -h 00 01 1 10 1
169170
'

t/t2400-worktree-add.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='test git worktree add'
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_CREATE_REPO_NO_TEMPLATE=1
89
. ./test-lib.sh
910

1011
. "$TEST_DIRECTORY"/lib-rebase.sh
@@ -229,6 +230,7 @@ test_expect_success 'checkout with grafts' '
229230
SHA1=$(git rev-parse HEAD) &&
230231
test_commit def &&
231232
test_commit xyz &&
233+
mkdir .git/info &&
232234
echo "$(git rev-parse HEAD) $SHA1" >.git/info/grafts &&
233235
cat >expected <<-\EOF &&
234236
xyz
@@ -559,6 +561,8 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' '
559561
'
560562

561563
post_checkout_hook () {
564+
test_when_finished "rm -rf .git/hooks" &&
565+
mkdir .git/hooks &&
562566
test_hook -C "$1" post-checkout <<-\EOF
563567
{
564568
echo $*

t/t5318-commit-graph.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,14 @@ test_expect_success 'replace-objects invalidates commit-graph' '
361361
test_expect_success 'commit grafts invalidate commit-graph' '
362362
cd "$TRASH_DIRECTORY" &&
363363
test_when_finished rm -rf graft &&
364-
git clone full graft &&
364+
git clone --template= full graft &&
365365
(
366366
cd graft &&
367367
git commit-graph write --reachable &&
368368
test_path_is_file .git/objects/info/commit-graph &&
369369
H1=$(git rev-parse --verify HEAD~1) &&
370370
H3=$(git rev-parse --verify HEAD~3) &&
371+
mkdir .git/info &&
371372
echo "$H1 $H3" >.git/info/grafts &&
372373
git -c core.commitGraph=false log >expect &&
373374
git -c core.commitGraph=true log >actual &&

t/t6001-rev-list-graft.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ do
9999
"
100100

101101
test_expect_success 'with grafts' "
102+
mkdir -p .git/info &&
102103
echo '$B0 $A2' >.git/info/grafts &&
103104
check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0
104105
"

t/t6101-rev-parse-parents.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test_description='Test git rev-parse with different parent options'
88
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
99
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1010

11+
TEST_CREATE_REPO_NO_TEMPLATE=1
1112
. ./test-lib.sh
1213

1314
test_cmp_rev_output () {
@@ -25,6 +26,7 @@ test_expect_success 'setup' '
2526
git merge -m next --allow-unrelated-histories start2 &&
2627
test_commit final &&
2728
29+
mkdir .git/info &&
2830
test_seq 40 |
2931
while read i
3032
do

t/t8001-annotate.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='git annotate'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_CREATE_REPO_NO_TEMPLATE=1
78
. ./test-lib.sh
89

910
PROG='git annotate'

t/t8002-blame.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='git blame'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_CREATE_REPO_NO_TEMPLATE=1
78
. ./test-lib.sh
89

910
PROG='git blame -c'

t/t8012-blame-colors.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='colored git blame'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_CREATE_REPO_NO_TEMPLATE=1
78
. ./test-lib.sh
89

910
PROG='git blame -c'

0 commit comments

Comments
 (0)