@@ -179,22 +179,26 @@ init_repos_as_submodules () {
179
179
}
180
180
181
181
run_on_sparse () {
182
+ cat > run-on-sparse-input &&
183
+
182
184
(
183
185
cd sparse-checkout &&
184
186
GIT_PROGRESS_DELAY=100000 " $@ " > ../sparse-checkout-out 2> ../sparse-checkout-err
185
- ) &&
187
+ ) < run-on-sparse-input &&
186
188
(
187
189
cd sparse-index &&
188
190
GIT_PROGRESS_DELAY=100000 " $@ " > ../sparse-index-out 2> ../sparse-index-err
189
- )
191
+ ) < run-on-sparse-input
190
192
}
191
193
192
194
run_on_all () {
195
+ cat > run-on-all-input &&
196
+
193
197
(
194
198
cd full-checkout &&
195
199
GIT_PROGRESS_DELAY=100000 " $@ " > ../full-checkout-out 2> ../full-checkout-err
196
- ) &&
197
- run_on_sparse " $@ "
200
+ ) < run-on-all-input &&
201
+ run_on_sparse " $@ " < run-on-all-input
198
202
}
199
203
200
204
test_all_match () {
@@ -221,7 +225,7 @@ test_sparse_unstaged () {
221
225
done
222
226
}
223
227
224
- # Usage: test_sprase_checkout_set "<c1> ... <cN>" "<s1> ... <sM>"
228
+ # Usage: test_sparse_checkout_set "<c1> ... <cN>" "<s1> ... <sM>"
225
229
# Verifies that "git sparse-checkout set <c1> ... <cN>" succeeds and
226
230
# leaves the sparse index in a state where <s1> ... <sM> are sparse
227
231
# directories (and <c1> ... <cN> are not).
@@ -2354,4 +2358,40 @@ test_expect_success 'advice.sparseIndexExpanded' '
2354
2358
grep "The sparse index is expanding to a full index" err
2355
2359
'
2356
2360
2361
+ test_expect_success ' cat-file -p' '
2362
+ init_repos &&
2363
+ echo "new content" >>full-checkout/deep/a &&
2364
+ echo "new content" >>sparse-checkout/deep/a &&
2365
+ echo "new content" >>sparse-index/deep/a &&
2366
+ run_on_all git add deep/a &&
2367
+
2368
+ test_all_match git cat-file -p :deep/a &&
2369
+ ensure_not_expanded cat-file -p :deep/a &&
2370
+ test_all_match git cat-file -p :folder1/a &&
2371
+ ensure_expanded cat-file -p :folder1/a
2372
+ '
2373
+
2374
+ test_expect_success ' cat-file --batch' '
2375
+ init_repos &&
2376
+ echo "new content" >>full-checkout/deep/a &&
2377
+ echo "new content" >>sparse-checkout/deep/a &&
2378
+ echo "new content" >>sparse-index/deep/a &&
2379
+ run_on_all git add deep/a &&
2380
+
2381
+ echo ":deep/a" >in &&
2382
+ test_all_match git cat-file --batch <in &&
2383
+ ensure_not_expanded cat-file --batch <in &&
2384
+
2385
+ echo ":folder1/a" >in &&
2386
+ test_all_match git cat-file --batch <in &&
2387
+ ensure_expanded cat-file --batch <in &&
2388
+
2389
+ cat >in <<-\EOF &&
2390
+ :deep/a
2391
+ :folder1/a
2392
+ EOF
2393
+ test_all_match git cat-file --batch <in &&
2394
+ ensure_expanded cat-file --batch <in
2395
+ '
2396
+
2357
2397
test_done
0 commit comments