Skip to content

Commit 3a9a6ac

Browse files
derrickstoleegitster
authored andcommitted
t1092: replace 'read-cache --table' with 'ls-files --sparse'
Now that 'git ls-files --sparse' exists, we can use it to verify the state of a sparse index instead of 'test-tool read-cache table'. Replace these usages within t1092-sparse-checkout-compatibility.sh. The important changes are due to the different output format. We need to use the '--stage' output to get a file mode and OID, but it also includes a stage value and drops the object type. This leads to some differences in how we handle looking for specific entries. Some places where we previously looked for no 'tree' entries, we can instead directly compare the output across the repository with a sparse index and the one without. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7808709 commit 3a9a6ac

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -206,45 +206,42 @@ test_sparse_unstaged () {
206206
test_expect_success 'sparse-index contents' '
207207
init_repos &&
208208
209-
test-tool -C sparse-index read-cache --table >cache &&
209+
git -C sparse-index ls-files --sparse --stage >cache &&
210210
for dir in folder1 folder2 x
211211
do
212212
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
213-
grep "040000 tree $TREE $dir/" cache \
213+
grep "040000 $TREE 0 $dir/" cache \
214214
|| return 1
215215
done &&
216216
217217
git -C sparse-index sparse-checkout set folder1 &&
218218
219-
test-tool -C sparse-index read-cache --table >cache &&
219+
git -C sparse-index ls-files --sparse --stage >cache &&
220220
for dir in deep folder2 x
221221
do
222222
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
223-
grep "040000 tree $TREE $dir/" cache \
223+
grep "040000 $TREE 0 $dir/" cache \
224224
|| return 1
225225
done &&
226226
227227
git -C sparse-index sparse-checkout set deep/deeper1 &&
228228
229-
test-tool -C sparse-index read-cache --table >cache &&
229+
git -C sparse-index ls-files --sparse --stage >cache &&
230230
for dir in deep/deeper2 folder1 folder2 x
231231
do
232232
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
233-
grep "040000 tree $TREE $dir/" cache \
233+
grep "040000 $TREE 0 $dir/" cache \
234234
|| return 1
235235
done &&
236236
237-
# Disabling the sparse-index removes tree entries with full ones
237+
# Disabling the sparse-index replaces tree entries with full ones
238238
git -C sparse-index sparse-checkout init --no-sparse-index &&
239-
240-
test-tool -C sparse-index read-cache --table >cache &&
241-
! grep "040000 tree" cache &&
242-
test_sparse_match test-tool read-cache --table
239+
test_sparse_match git ls-files --stage --sparse
243240
'
244241

245242
test_expect_success 'expanded in-memory index matches full index' '
246243
init_repos &&
247-
test_sparse_match test-tool read-cache --expand --table
244+
test_sparse_match git ls-files --stage
248245
'
249246

250247
test_expect_success 'status with options' '
@@ -801,9 +798,9 @@ test_expect_success 'submodule handling' '
801798
802799
# having a submodule prevents "modules" from collapse
803800
test_sparse_match git sparse-checkout set deep/deeper1 &&
804-
test-tool -C sparse-index read-cache --table >cache &&
805-
grep "100644 blob .* modules/a" cache &&
806-
grep "160000 commit $(git -C initial-repo rev-parse HEAD) modules/sub" cache
801+
git -C sparse-index ls-files --sparse --stage >cache &&
802+
grep "100644 .* modules/a" cache &&
803+
grep "160000 $(git -C initial-repo rev-parse HEAD) 0 modules/sub" cache
807804
'
808805

809806
# When working with a sparse index, some commands will need to expand the
@@ -1125,13 +1122,13 @@ test_expect_success 'reset mixed and checkout orphan' '
11251122
# the sparse checkouts skip "adding" the other side of
11261123
# the conflict.
11271124
test_sparse_match git reset --mixed HEAD~1 &&
1128-
test_sparse_match test-tool read-cache --table --expand &&
1125+
test_sparse_match git ls-files --stage &&
11291126
test_sparse_match git status --porcelain=v2 &&
11301127
11311128
# At this point, sparse-checkouts behave differently
11321129
# from the full-checkout.
11331130
test_sparse_match git checkout --orphan new-branch &&
1134-
test_sparse_match test-tool read-cache --table --expand &&
1131+
test_sparse_match git ls-files --stage &&
11351132
test_sparse_match git status --porcelain=v2
11361133
'
11371134

0 commit comments

Comments
 (0)