Skip to content

Commit 0194c3c

Browse files
committed
Merge branch 'ab/test-without-templates' into seen
source: <[email protected]> * ab/test-without-templates: tests: don't assume a .git/info for .git/info/sparse-checkout tests: don't assume a .git/info for .git/info/exclude tests: don't assume a .git/info for .git/info/refs tests: don't assume a .git/info for .git/info/attributes tests: don't assume a .git/info for .git/info/grafts tests: don't depend on template-created .git/branches t0008: don't rely on default ".git/info/exclude"
2 parents c21754a + ead7460 commit 0194c3c

30 files changed

+97
-27
lines changed

t/annotate-tests.sh

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

154154
test_expect_success 'blame huge graft' '
155155
test_when_finished "git checkout branch2" &&
156-
test_when_finished "rm -f .git/info/grafts" &&
156+
test_when_finished "rm -rf .git/info" &&
157157
graft= &&
158158
for i in 0 1 2
159159
do
@@ -168,6 +168,7 @@ test_expect_success 'blame huge graft' '
168168
graft="$graft$commit " || return 1
169169
done
170170
done &&
171+
mkdir .git/info &&
171172
printf "%s " $graft >.git/info/grafts &&
172173
check_count -h 00 01 1 10 1
173174
'

t/lib-submodule-update.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ prolog () {
207207
# should be updated to an existing commit.
208208
reset_work_tree_to () {
209209
rm -rf submodule_update &&
210-
git clone submodule_update_repo submodule_update &&
210+
git clone --template= submodule_update_repo submodule_update &&
211211
(
212212
cd submodule_update &&
213213
rm -rf sub1 &&
@@ -902,13 +902,14 @@ test_submodule_switch_recursing_with_args () {
902902
'
903903
# ... but an ignored file is fine.
904904
test_expect_$RESULTOI "$command: added submodule removes an untracked ignored file" '
905-
test_when_finished "rm submodule_update/.git/info/exclude" &&
905+
test_when_finished "rm -rf submodule_update/.git/info" &&
906906
prolog &&
907907
reset_work_tree_to_interested no_submodule &&
908908
(
909909
cd submodule_update &&
910910
git branch -t add_sub1 origin/add_sub1 &&
911911
: >sub1 &&
912+
mkdir .git/info &&
912913
echo sub1 >.git/info/exclude &&
913914
$command add_sub1 &&
914915
test_superproject_content origin/add_sub1 &&
@@ -951,7 +952,9 @@ test_submodule_switch_recursing_with_args () {
951952
reset_work_tree_to_interested add_sub1 &&
952953
(
953954
cd submodule_update &&
955+
rm -rf .git/modules/sub1/info &&
954956
git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
957+
mkdir .git/modules/sub1/info &&
955958
echo ignored >.git/modules/sub1/info/exclude &&
956959
: >sub1/ignored &&
957960
$command replace_sub1_with_file &&

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/t0008-ignores.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
test_description=check-ignore
44

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

89
init_vars () {
@@ -225,7 +226,8 @@ test_expect_success 'setup' '
225226
!globaltwo
226227
globalthree
227228
EOF
228-
cat <<-\EOF >>.git/info/exclude
229+
mkdir .git/info &&
230+
cat <<-\EOF >.git/info/exclude
229231
per-repo
230232
EOF
231233
'
@@ -543,9 +545,9 @@ test_expect_success_multi 'submodule from subdirectory' '' '
543545

544546
test_expect_success 'global ignore not yet enabled' '
545547
expect_from_stdin <<-\EOF &&
546-
.git/info/exclude:7:per-repo per-repo
548+
.git/info/exclude:1:per-repo per-repo
547549
a/.gitignore:2:*three a/globalthree
548-
.git/info/exclude:7:per-repo a/per-repo
550+
.git/info/exclude:1:per-repo a/per-repo
549551
EOF
550552
test_check_ignore "-v globalone per-repo a/globalthree a/per-repo not-ignored a/globaltwo"
551553
'
@@ -566,10 +568,10 @@ test_expect_success 'global ignore with -v' '
566568
enable_global_excludes &&
567569
expect_from_stdin <<-EOF &&
568570
$global_excludes:1:globalone globalone
569-
.git/info/exclude:7:per-repo per-repo
571+
.git/info/exclude:1:per-repo per-repo
570572
$global_excludes:3:globalthree globalthree
571573
a/.gitignore:2:*three a/globalthree
572-
.git/info/exclude:7:per-repo a/per-repo
574+
.git/info/exclude:1:per-repo a/per-repo
573575
$global_excludes:2:!globaltwo globaltwo
574576
EOF
575577
test_check_ignore "-v globalone per-repo globalthree a/globalthree a/per-repo not-ignored globaltwo"

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/t1011-read-tree-sparse-checkout.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ test_description='sparse checkout tests
1111
A init.t
1212
'
1313

14+
TEST_CREATE_REPO_NO_TEMPLATE=1
1415
. ./test-lib.sh
1516
. "$TEST_DIRECTORY"/lib-read-tree.sh
1617

@@ -53,6 +54,7 @@ test_expect_success 'read-tree without .git/info/sparse-checkout' '
5354
'
5455

5556
test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
57+
mkdir .git/info &&
5658
echo >.git/info/sparse-checkout &&
5759
read_tree_u_must_succeed -m -u HEAD &&
5860
git ls-files -t >result &&

t/t1090-sparse-checkout-scope.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='sparse checkout scope tests'
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_expect_success 'setup' '
@@ -25,6 +26,7 @@ test_expect_success 'create feature branch' '
2526

2627
test_expect_success 'perform sparse checkout of main' '
2728
git config --local --bool core.sparsecheckout true &&
29+
mkdir .git/info &&
2830
echo "!/*" >.git/info/sparse-checkout &&
2931
echo "/a" >>.git/info/sparse-checkout &&
3032
echo "/c" >>.git/info/sparse-checkout &&
@@ -73,7 +75,7 @@ test_expect_success 'skip-worktree on files outside sparse patterns' '
7375

7476
test_expect_success 'in partial clone, sparse checkout only fetches needed blobs' '
7577
test_create_repo server &&
76-
git clone "file://$(pwd)/server" client &&
78+
git clone --template= "file://$(pwd)/server" client &&
7779
7880
test_config -C server uploadpack.allowfilter 1 &&
7981
test_config -C server uploadpack.allowanysha1inwant 1 &&
@@ -85,6 +87,7 @@ test_expect_success 'in partial clone, sparse checkout only fetches needed blobs
8587
git -C server commit -m message &&
8688
8789
test_config -C client core.sparsecheckout 1 &&
90+
mkdir client/.git/info &&
8891
echo "!/*" >client/.git/info/sparse-checkout &&
8992
echo "/a" >>client/.git/info/sparse-checkout &&
9093
git -C client fetch --filter=blob:none origin &&

t/t1301-shared-repo.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ done
4848
test_expect_success 'shared=all' '
4949
mkdir sub &&
5050
cd sub &&
51-
git init --shared=all &&
51+
git init --template= --shared=all &&
5252
test 2 = $(git config core.sharedrepository)
5353
'
5454

@@ -57,6 +57,7 @@ test_expect_success POSIXPERM 'update-server-info honors core.sharedRepository'
5757
git add a1 &&
5858
test_tick &&
5959
git commit -m a1 &&
60+
mkdir .git/info &&
6061
umask 0277 &&
6162
git update-server-info &&
6263
actual="$(ls -l .git/info/refs)" &&

t/t2018-checkout-branch.sh

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

33
test_description='checkout'
44

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

78
# Arguments: [!] <branch> <oid> [<checkout options>]
@@ -257,11 +258,12 @@ test_expect_success 'checkout -b to a new branch preserves mergeable changes des
257258
git checkout branch1-scratch &&
258259
test_might_fail git branch -D branch3 &&
259260
git config core.sparseCheckout false &&
260-
rm .git/info/sparse-checkout" &&
261+
rm -rf .git/info" &&
261262
262263
test_commit file2 &&
263264
264265
echo stuff >>file1 &&
266+
mkdir .git/info &&
265267
echo file2 >.git/info/sparse-checkout &&
266268
git config core.sparseCheckout true &&
267269

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/t3426-rebase-submodule.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ git_rebase_interactive () {
3535
ls -1pR * >>actual &&
3636
test_cmp expect actual &&
3737
set_fake_editor &&
38+
mkdir .git/info &&
3839
echo "fake-editor.sh" >.git/info/exclude &&
3940
may_only_be_test_must_fail "$2" &&
4041
$2 git rebase -i "$1"

t/t3507-cherry-pick-conflict.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ test_description='test cherry-pick and revert with conflicts
1212
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
1313
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1414

15+
TEST_CREATE_REPO_NO_TEMPLATE=1
1516
. ./test-lib.sh
1617

1718
pristine_detach () {
@@ -558,6 +559,7 @@ test_expect_success 'cherry-pick preserves sparse-checkout' '
558559
echo \"/*\" >.git/info/sparse-checkout
559560
git read-tree --reset -u HEAD
560561
rm .git/info/sparse-checkout" &&
562+
mkdir .git/info &&
561563
echo /unrelated >.git/info/sparse-checkout &&
562564
git read-tree --reset -u HEAD &&
563565
test_must_fail git cherry-pick -Xours picked>actual &&

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.

0 commit comments

Comments
 (0)