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 <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Dec 22, 2021 at 14:20 UTC
3a9a6ac5d9df68152795e66acba02afd928bf705
1 file changed
+14
-17
t/t1092-sparse-checkout-compatibility.sh
+14
-17
@@ -206,45 +206,42 @@ test_sparse_unstaged () {
206
test_expect_success 'sparse-index contents' '
207
init_repos &&
208
209
- test-tool -C sparse-index read-cache --table >cache &&
209
+ git -C sparse-index ls-files --sparse --stage >cache &&
210
for dir in folder1 folder2 x
211
do
212
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
213
- grep "040000 tree $TREE $dir/" cache \
213
+ grep "040000 $TREE 0 $dir/" cache \
214
|| return 1
215
done &&
216
217
git -C sparse-index sparse-checkout set folder1 &&
218
219
- test-tool -C sparse-index read-cache --table >cache &&
219
+ git -C sparse-index ls-files --sparse --stage >cache &&
220
for dir in deep folder2 x
221
do
222
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
223
- grep "040000 tree $TREE $dir/" cache \
223
+ grep "040000 $TREE 0 $dir/" cache \
224
|| return 1
225
done &&
226
227
git -C sparse-index sparse-checkout set deep/deeper1 &&
228
229
- test-tool -C sparse-index read-cache --table >cache &&
229
+ git -C sparse-index ls-files --sparse --stage >cache &&
230
for dir in deep/deeper2 folder1 folder2 x
231
do
232
TREE=$(git -C sparse-index rev-parse HEAD:$dir) &&
233
- grep "040000 tree $TREE $dir/" cache \
233
+ grep "040000 $TREE 0 $dir/" cache \
234
|| return 1
235
done &&
236
237
- # Disabling the sparse-index removes tree entries with full ones
237
+ # Disabling the sparse-index replaces tree entries with full ones
238
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
240
'
241
242
test_expect_success 'expanded in-memory index matches full index' '
243
init_repos &&
247
- test_sparse_match test-tool read-cache --expand --table
244
+ test_sparse_match git ls-files --stage
245
'
246
247
test_expect_success 'status with options' '
@@ -801,9 +798,9 @@ test_expect_success 'submodule handling' '
798
799
# having a submodule prevents "modules" from collapse
800
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
804
'
805
806
# 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' '
1122
# the sparse checkouts skip "adding" the other side of
1123
# the conflict.
1124
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 &&
1126
test_sparse_match git status --porcelain=v2 &&
1127
1128
# At this point, sparse-checkouts behave differently
1129
# from the full-checkout.
1130
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 &&
1132
test_sparse_match git status --porcelain=v2
1133
'
1134