tests: don't assume a .git/info for .git/info/sparse-checkout
Change those tests that assumed that a .git/info directory would be created for them when writing .git/info/sparse-checkout 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". 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
ead74601c6ed7171e9e736e329b45c12d90153e4
6 files changed
+15
-3
t/t1011-read-tree-sparse-checkout.sh
+2
@@ -11,6 +11,7 @@ test_description='sparse checkout tests
11
A init.t
12
'
13
14
+TEST_CREATE_REPO_NO_TEMPLATE=1
15
. ./test-lib.sh
16
. "$TEST_DIRECTORY"/lib-read-tree.sh
17
@@ -53,6 +54,7 @@ test_expect_success 'read-tree without .git/info/sparse-checkout' '
54
'
55
56
test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
57
+ mkdir .git/info &&
58
echo >.git/info/sparse-checkout &&
59
read_tree_u_must_succeed -m -u HEAD &&
60
git ls-files -t >result &&
t/t1090-sparse-checkout-scope.sh
+4
-1
@@ -5,6 +5,7 @@ test_description='sparse checkout scope tests'
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_expect_success 'setup' '
@@ -25,6 +26,7 @@ test_expect_success 'create feature branch' '
26
27
test_expect_success 'perform sparse checkout of main' '
28
git config --local --bool core.sparsecheckout true &&
29
+ mkdir .git/info &&
30
echo "!/*" >.git/info/sparse-checkout &&
31
echo "/a" >>.git/info/sparse-checkout &&
32
echo "/c" >>.git/info/sparse-checkout &&
@@ -73,7 +75,7 @@ test_expect_success 'skip-worktree on files outside sparse patterns' '
75
76
test_expect_success 'in partial clone, sparse checkout only fetches needed blobs' '
77
test_create_repo server &&
76
- git clone "file://$(pwd)/server" client &&
78
+ git clone --template= "file://$(pwd)/server" client &&
79
80
test_config -C server uploadpack.allowfilter 1 &&
81
test_config -C server uploadpack.allowanysha1inwant 1 &&
@@ -85,6 +87,7 @@ test_expect_success 'in partial clone, sparse checkout only fetches needed blobs
87
git -C server commit -m message &&
88
89
test_config -C client core.sparsecheckout 1 &&
90
+ mkdir client/.git/info &&
91
echo "!/*" >client/.git/info/sparse-checkout &&
92
echo "/a" >>client/.git/info/sparse-checkout &&
93
git -C client fetch --filter=blob:none origin &&
t/t2018-checkout-branch.sh
+3
-1
@@ -2,6 +2,7 @@
2
3
test_description='checkout'
4
5
+TEST_CREATE_REPO_NO_TEMPLATE=1
6
. ./test-lib.sh
7
8
# Arguments: [!] <branch> <oid> [<checkout options>]
@@ -257,11 +258,12 @@ test_expect_success 'checkout -b to a new branch preserves mergeable changes des
258
git checkout branch1-scratch &&
259
test_might_fail git branch -D branch3 &&
260
git config core.sparseCheckout false &&
260
- rm .git/info/sparse-checkout" &&
261
+ rm -rf .git/info" &&
262
263
test_commit file2 &&
264
265
echo stuff >>file1 &&
266
+ mkdir .git/info &&
267
echo file2 >.git/info/sparse-checkout &&
268
git config core.sparseCheckout true &&
269
t/t3507-cherry-pick-conflict.sh
+2
@@ -12,6 +12,7 @@ test_description='test cherry-pick and revert with conflicts
12
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
13
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
14
15
+TEST_CREATE_REPO_NO_TEMPLATE=1
16
. ./test-lib.sh
17
18
pristine_detach () {
@@ -558,6 +559,7 @@ test_expect_success 'cherry-pick preserves sparse-checkout' '
559
echo \"/*\" >.git/info/sparse-checkout
560
git read-tree --reset -u HEAD
561
rm .git/info/sparse-checkout" &&
562
+ mkdir .git/info &&
563
echo /unrelated >.git/info/sparse-checkout &&
564
git read-tree --reset -u HEAD &&
565
test_must_fail git cherry-pick -Xours picked>actual &&
t/t6435-merge-sparse.sh
+2
@@ -2,6 +2,7 @@
2
3
test_description='merge with sparse files'
4
5
+TEST_CREATE_REPO_NO_TEMPLATE=1
6
. ./test-lib.sh
7
8
# test_file $filename $content
@@ -26,6 +27,7 @@ test_expect_success 'setup' '
27
git rm modify_delete &&
28
test_commit_this ours &&
29
git config core.sparseCheckout true &&
30
+ mkdir .git/info &&
31
echo "/checked-out" >.git/info/sparse-checkout &&
32
git reset --hard &&
33
test_must_fail git merge theirs
t/t7418-submodule-sparse-gitmodules.sh
+2
-1
@@ -31,8 +31,9 @@ test_expect_success 'sparse checkout setup which hides .gitmodules' '
31
test_tick &&
32
git commit -m "Add submodule"
33
) &&
34
- git clone upstream super &&
34
+ git clone --template= upstream super &&
35
(cd super &&
36
+ mkdir .git/info &&
37
cat >.git/info/sparse-checkout <<-\EOF &&
38
/*
39
!/.gitmodules