t1091/t3705: remove 'test-tool read-cache --table'

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 t1091-sparse-checkout-builtin.sh and t3705-add-sparse-checkout.sh. The important changes are due to the different output format. In t3705, 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. In t1091, the test focuses on enabling the sparse index, so we do not need the --stage flag to demonstrate how the index changes, and instead can use a diff. 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 c2a2940510579bad9f5c63797542c47f14e8a2da
2 files changed +24 -9
t/t1091-sparse-checkout-builtin.sh
+20 -5
@@ -212,12 +212,27 @@ test_expect_success 'sparse-index enabled and disabled' '
212
213 git -C repo sparse-checkout init --cone --sparse-index &&
214 test_cmp_config -C repo true index.sparse &&
215 - test-tool -C repo read-cache --table >cache &&
216 - grep " tree " cache &&
217 -
215 + git -C repo ls-files --sparse >sparse &&
216 git -C repo sparse-checkout disable &&
219 - test-tool -C repo read-cache --table >cache &&
220 - ! grep " tree " cache &&
217 + git -C repo ls-files --sparse >full &&
218 +
219 + cat >expect <<-\EOF &&
220 + @@ -1,4 +1,7 @@
221 + a
222 + -deep/
223 + -folder1/
224 + -folder2/
225 + +deep/a
226 + +deep/deeper1/a
227 + +deep/deeper1/deepest/a
228 + +deep/deeper2/a
229 + +folder1/a
230 + +folder2/a
231 + EOF
232 +
233 + diff -u sparse full | tail -n +3 >actual &&
234 + test_cmp expect actual &&
235 +
236 git -C repo config --list >config &&
237 ! grep index.sparse config
238 )
t/t3705-add-sparse-checkout.sh
+4 -4
@@ -181,13 +181,13 @@ test_expect_success 'git add fails outside of sparse-checkout definition' '
181 # Avoid munging CRLFs to avoid an error message
182 git -c core.autocrlf=input add --sparse sparse_entry 2>stderr &&
183 test_must_be_empty stderr &&
184 - test-tool read-cache --table >actual &&
185 - grep "^100644 blob.*sparse_entry\$" actual &&
184 + git ls-files --stage >actual &&
185 + grep "^100644 .*sparse_entry\$" actual &&
186
187 git add --sparse --chmod=+x sparse_entry 2>stderr &&
188 test_must_be_empty stderr &&
189 - test-tool read-cache --table >actual &&
190 - grep "^100755 blob.*sparse_entry\$" actual &&
189 + git ls-files --stage >actual &&
190 + grep "^100755 .*sparse_entry\$" actual &&
191
192 git reset &&
193