Skip to content

Commit ead7460

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

6 files changed

+15
-3
lines changed

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/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/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/t6435-merge-sparse.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='merge with sparse files'
44

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

78
# test_file $filename $content
@@ -26,6 +27,7 @@ test_expect_success 'setup' '
2627
git rm modify_delete &&
2728
test_commit_this ours &&
2829
git config core.sparseCheckout true &&
30+
mkdir .git/info &&
2931
echo "/checked-out" >.git/info/sparse-checkout &&
3032
git reset --hard &&
3133
test_must_fail git merge theirs

t/t7418-submodule-sparse-gitmodules.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ test_expect_success 'sparse checkout setup which hides .gitmodules' '
3131
test_tick &&
3232
git commit -m "Add submodule"
3333
) &&
34-
git clone upstream super &&
34+
git clone --template= upstream super &&
3535
(cd super &&
36+
mkdir .git/info &&
3637
cat >.git/info/sparse-checkout <<-\EOF &&
3738
/*
3839
!/.gitmodules

0 commit comments

Comments
 (0)