73
expect*
74
actual*
75
marker*
76
+ trace2*
77
EOF
78
'
79
384
)
385
'
386
387
+# Usage:
388
+# check_sparse_index_behavior [!]
389
+# If "!" is supplied, then we verify that we do not call ensure_full_index
390
+# during a call to 'git status'. Otherwise, we verify that we _do_ call it.
391
+check_sparse_index_behavior () {
392
+ git status --porcelain=v2 >expect &&
393
+ git sparse-checkout init --cone --sparse-index &&
394
+ git sparse-checkout set dir1 dir2 &&
395
+ GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
396
+ git status --porcelain=v2 >actual &&
397
+ test_region $1 index ensure_full_index trace2.txt &&
398
+ test_region fsm_hook query trace2.txt &&
399
+ test_cmp expect actual &&
400
+ rm trace2.txt &&
401
+ git sparse-checkout disable
402
+}
403
+
404
+test_expect_success 'status succeeds with sparse index' '
405
+ git reset --hard &&
406
+
407
+ test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" &&
408
+ check_sparse_index_behavior ! &&
409
+
410
+ write_script .git/hooks/fsmonitor-test<<-\EOF &&
411
+ printf "last_update_token\0"
412
+ EOF
413
+ git config core.fsmonitor .git/hooks/fsmonitor-test &&
414
+ check_sparse_index_behavior ! &&
415
+
416
+ write_script .git/hooks/fsmonitor-test<<-\EOF &&
417
+ printf "last_update_token\0"
418
+ printf "dir1/modified\0"
419
+ EOF
420
+ check_sparse_index_behavior ! &&
421
+
422
+ cp -r dir1 dir1a &&
423
+ git add dir1a &&
424
+ git commit -m "add dir1a" &&
425
+
426
+ # This one modifies outside the sparse-checkout definition
427
+ # and hence we expect to expand the sparse-index.
428
+ write_script .git/hooks/fsmonitor-test<<-\EOF &&
429
+ printf "last_update_token\0"
430
+ printf "dir1a/modified\0"
431
+ EOF
432
+ check_sparse_index_behavior
433
+'
434
+
435
test_done