Skip to content

Commit 8846847

Browse files
derrickstoleegitster
authored andcommitted
t1092: stress test 'git sparse-checkout set'
The 'sparse-index contents' test checks that the sparse index has the correct set of sparse directories in the index after modifying the cone mode patterns using 'git sparse-checkout set'. Add to the coverage here by adding more complicated scenarios that were not previously tested. In order to check paths that do not exist at HEAD, we need to modify the test_sparse_checkout_set helper slightly: 1. Add the --skip-checks argument to the 'set' command to avoid failures when passing paths that do not exist at HEAD. 2. When looking for the non-existence of sparse directories for the paths in $CONE_DIRS, allow the rev-list command to fail because the path does not exist at HEAD. This allows us to add some interesting test cases. Helped-by: Victoria Dye <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent baa73e2 commit 8846847

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ test_sparse_unstaged () {
212212
test_sparse_checkout_set () {
213213
CONE_DIRS=$1 &&
214214
SPARSE_DIRS=$2 &&
215-
git -C sparse-index sparse-checkout set $CONE_DIRS &&
215+
git -C sparse-index sparse-checkout set --skip-checks $CONE_DIRS &&
216216
git -C sparse-index ls-files --sparse --stage >cache &&
217217

218218
# Check that the directories outside of the sparse-checkout cone
@@ -228,7 +228,9 @@ test_sparse_checkout_set () {
228228
# are not sparse directory entries.
229229
for dir in $CONE_DIRS
230230
do
231-
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
231+
# Allow TREE to not exist because
232+
# $dir does not exist at HEAD.
233+
TREE=$(git -C sparse-index rev-parse HEAD:$dir) ||
232234
! grep "040000 $TREE 0 $dir/" cache \
233235
|| return 1
234236
done
@@ -253,6 +255,19 @@ test_expect_success 'sparse-index contents' '
253255
"deep/deeper2 folder1 folder2 x" \
254256
"before deep/deeper1" &&
255257
258+
# Replace deep/deeper2 with deep/deeper1
259+
# Replace folder1 with folder1/0/0
260+
# Replace folder2 with non-existent folder2/2/3
261+
# Add non-existent "bogus"
262+
test_sparse_checkout_set \
263+
"bogus deep/deeper1 folder1/0/0 folder2/2/3 x" \
264+
"before deep/deeper2 folder2/0" &&
265+
266+
# Drop down to only files at root
267+
test_sparse_checkout_set \
268+
"" \
269+
"before deep folder1 folder2 x" &&
270+
256271
# Disabling the sparse-index replaces tree entries with full ones
257272
git -C sparse-index sparse-checkout init --no-sparse-index &&
258273
test_sparse_match git ls-files --stage --sparse

0 commit comments

Comments
 (0)