Skip to content

Commit 8da0b02

Browse files
avargitster
authored andcommitted
tests: don't assume a .git/info for .git/info/attributes
Change those tests that assumed that a .git/info directory would be created for them when writing .git/info/attributes 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". The change here in here in t7814-grep-recurse-submodules.sh would continue "succeeding" with only the "TEST_CREATE_REPO_NO_TEMPLATE=1" part of this change. That's because those tests use "test_expect_failure", so they'd "pass" without this change, as "test_expect_failure" by design isn't discerning about what failure conditions it'll accept. But as we're fixing these sorts of issues across the test suite let's fix this one too. This issue was spotted with a local merge with another topic of mine[1], which introduces a stricter alternative to "test_expect_failure". 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 93e02b6 commit 8da0b02

7 files changed

+28
-7
lines changed

t/t0003-attributes.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
test_description=gitattributes
44

55
TEST_PASSES_SANITIZE_LEAK=true
6+
TEST_CREATE_REPO_NO_TEMPLATE=1
67
. ./test-lib.sh
78

89
attr_check_basic () {
@@ -284,7 +285,7 @@ test_expect_success 'using --git-dir and --work-tree' '
284285
'
285286

286287
test_expect_success 'setup bare' '
287-
git clone --bare . bare.git
288+
git clone --template= --bare . bare.git
288289
'
289290

290291
test_expect_success 'bare repository: check that .gitattribute is ignored' '
@@ -315,6 +316,7 @@ test_expect_success 'bare repository: check that --cached honors index' '
315316
test_expect_success 'bare repository: test info/attributes' '
316317
(
317318
cd bare.git &&
319+
mkdir info &&
318320
(
319321
echo "f test=f" &&
320322
echo "a/i test=a/i"
@@ -360,6 +362,7 @@ test_expect_success SYMLINKS 'symlinks respected in core.attributesFile' '
360362

361363
test_expect_success SYMLINKS 'symlinks respected in info/attributes' '
362364
test_when_finished "rm .git/info/attributes" &&
365+
mkdir .git/info &&
363366
ln -s ../../attr .git/info/attributes &&
364367
attr_check file set
365368
'

t/t0028-working-tree-encoding.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='working-tree-encoding conversion via gitattributes'
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
. "$TEST_DIRECTORY/lib-encoding.sh"
1011

@@ -69,6 +70,7 @@ test_expect_success 'check $GIT_DIR/info/attributes support' '
6970
test_when_finished "rm -f test.utf32.git" &&
7071
test_when_finished "git reset --hard HEAD" &&
7172
73+
mkdir .git/info &&
7274
echo "*.utf32 text working-tree-encoding=utf-32" >.git/info/attributes &&
7375
git add test.utf32 &&
7476

t/t5000-tar-tree.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ commit id embedding:
2424
2525
'
2626

27+
TEST_CREATE_REPO_NO_TEMPLATE=1
2728
. ./test-lib.sh
2829

2930
SUBSTFORMAT=%H%n
@@ -143,6 +144,7 @@ test_expect_success 'populate workdir' '
143144
test_expect_success \
144145
'add ignored file' \
145146
'echo ignore me >a/ignored &&
147+
mkdir .git/info &&
146148
echo ignored export-ignore >.git/info/attributes'
147149

148150
test_expect_success 'add files to repository' '
@@ -157,7 +159,8 @@ test_expect_success 'setup export-subst' '
157159
'
158160

159161
test_expect_success 'create bare clone' '
160-
git clone --bare . bare.git &&
162+
git clone --template= --bare . bare.git &&
163+
mkdir bare.git/info &&
161164
cp .git/info/attributes bare.git/info/attributes
162165
'
163166

t/t5001-archive-attr.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='git archive attribute tests'
44

5+
TEST_CREATE_REPO_NO_TEMPLATE=1
56
. ./test-lib.sh
67

78
SUBSTFORMAT='%H (%h)%n'
@@ -20,6 +21,7 @@ extract_tar_to_dir () {
2021

2122
test_expect_success 'setup' '
2223
echo ignored >ignored &&
24+
mkdir .git/info &&
2325
echo ignored export-ignore >>.git/info/attributes &&
2426
git add ignored &&
2527
@@ -46,7 +48,8 @@ test_expect_success 'setup' '
4648
4749
git commit -m. &&
4850
49-
git clone --bare . bare &&
51+
git clone --template= --bare . bare &&
52+
mkdir bare/info &&
5053
cp .git/info/attributes bare/info/attributes
5154
'
5255

t/t5002-archive-attr-pattern.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
test_description='git archive attribute pattern tests'
44

55
TEST_PASSES_SANITIZE_LEAK=true
6+
TEST_CREATE_REPO_NO_TEMPLATE=1
67
. ./test-lib.sh
78

89
test_expect_exists() {
@@ -15,6 +16,7 @@ test_expect_missing() {
1516

1617
test_expect_success 'setup' '
1718
echo ignored >ignored &&
19+
mkdir .git/info &&
1820
echo ignored export-ignore >>.git/info/attributes &&
1921
git add ignored &&
2022
@@ -54,7 +56,8 @@ test_expect_success 'setup' '
5456
5557
git commit -m. &&
5658
57-
git clone --bare . bare &&
59+
git clone --template= --bare . bare &&
60+
mkdir bare/info &&
5861
cp .git/info/attributes bare/info/attributes
5962
'
6063

t/t5003-archive-zip.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='git archive --format=zip test'
44

5+
TEST_CREATE_REPO_NO_TEMPLATE=1
56
. ./test-lib.sh
67

78
SUBSTFORMAT=%H%n
@@ -121,6 +122,7 @@ test_expect_success 'prepare file list' '
121122
test_expect_success \
122123
'add ignored file' \
123124
'echo ignore me >a/ignored &&
125+
mkdir .git/info &&
124126
echo ignored export-ignore >.git/info/attributes'
125127

126128
test_expect_success 'add files to repository' '
@@ -139,7 +141,8 @@ test_expect_success 'setup export-subst and diff attributes' '
139141
'
140142

141143
test_expect_success 'create bare clone' '
142-
git clone --bare . bare.git &&
144+
git clone --template= --bare . bare.git &&
145+
mkdir bare.git/info &&
143146
cp .git/info/attributes bare.git/info/attributes &&
144147
# Recreate our changes to .git/config rather than just copying it, as
145148
# we do not want to clobber core.bare or other settings.

t/t7814-grep-recurse-submodules.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This test verifies the recurse-submodules feature correctly greps across
66
submodules.
77
'
88

9+
TEST_CREATE_REPO_NO_TEMPLATE=1
910
. ./test-lib.sh
1011

1112
GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
@@ -471,8 +472,10 @@ test_expect_failure 'grep --textconv: superproject .gitattributes (from index) d
471472
test_expect_failure 'grep --textconv: superproject .git/info/attributes does not affect submodules' '
472473
reset_and_clean &&
473474
test_config_global diff.d2x.textconv "sed -e \"s/d/x/\"" &&
474-
super_attr="$(git rev-parse --git-path info/attributes)" &&
475+
super_info="$(git rev-parse --git-path info)" &&
476+
super_attr="$super_info/attributes" &&
475477
test_when_finished "rm -f \"$super_attr\"" &&
478+
mkdir "$super_info" &&
476479
echo "a diff=d2x" >"$super_attr" &&
477480
478481
cat >expect <<-\EOF &&
@@ -516,7 +519,8 @@ test_expect_failure 'grep --textconv correctly reads submodule .git/info/attribu
516519
reset_and_clean &&
517520
test_config_global diff.d2x.textconv "sed -e \"s/d/x/\"" &&
518521
519-
submodule_attr="$(git -C submodule rev-parse --path-format=absolute --git-path info/attributes)" &&
522+
submodule_info="$(git -C submodule rev-parse --path-format=absolute --git-path info)" &&
523+
submodule_attr="$submodule_info/attributes" &&
520524
test_when_finished "rm -f \"$submodule_attr\"" &&
521525
echo "a diff=d2x" >"$submodule_attr" &&
522526

0 commit comments

Comments
 (0)