@@ -354,4 +354,123 @@ EOF
354
354
test_cmp ../expect ../actual
355
355
'
356
356
357
+ test_expect_success ' set up for sparse checkout testing' '
358
+ echo two >done/.gitignore &&
359
+ echo three >>done/.gitignore &&
360
+ echo two >done/two &&
361
+ git add -f done/two done/.gitignore &&
362
+ git commit -m "first commit"
363
+ '
364
+
365
+ test_expect_success ' status after commit' '
366
+ : >../trace &&
367
+ GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
368
+ git status --porcelain >../actual &&
369
+ cat >../status.expect <<EOF &&
370
+ ?? .gitignore
371
+ ?? dtwo/
372
+ EOF
373
+ test_cmp ../status.expect ../actual &&
374
+ cat >../trace.expect <<EOF &&
375
+ node creation: 0
376
+ gitignore invalidation: 0
377
+ directory invalidation: 0
378
+ opendir: 1
379
+ EOF
380
+ test_cmp ../trace.expect ../trace
381
+ '
382
+
383
+ test_expect_success ' untracked cache correct after commit' '
384
+ test-dump-untracked-cache >../actual &&
385
+ cat >../expect <<EOF &&
386
+ info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
387
+ core.excludesfile 0000000000000000000000000000000000000000
388
+ exclude_per_dir .gitignore
389
+ flags 00000006
390
+ / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
391
+ .gitignore
392
+ dtwo/
393
+ /done/ 0000000000000000000000000000000000000000 recurse valid
394
+ /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
395
+ /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
396
+ two
397
+ EOF
398
+ test_cmp ../expect ../actual
399
+ '
400
+
401
+ test_expect_success ' set up sparse checkout' '
402
+ echo "done/[a-z]*" >.git/info/sparse-checkout &&
403
+ test_config core.sparsecheckout true &&
404
+ git checkout master &&
405
+ git update-index --untracked-cache &&
406
+ git status --porcelain >/dev/null && # prime the cache
407
+ test_path_is_missing done/.gitignore &&
408
+ test_path_is_file done/one
409
+ '
410
+
411
+ test_expect_success ' create files, some of which are gitignored' '
412
+ echo three >done/three && # three is gitignored
413
+ echo four >done/four && # four is gitignored at a higher level
414
+ echo five >done/five # five is not gitignored
415
+ '
416
+
417
+ test_expect_success ' test sparse status with untracked cache' '
418
+ : >../trace &&
419
+ avoid_racy &&
420
+ GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
421
+ git status --porcelain >../status.actual &&
422
+ cat >../status.expect <<EOF &&
423
+ ?? .gitignore
424
+ ?? done/five
425
+ ?? dtwo/
426
+ EOF
427
+ test_cmp ../status.expect ../status.actual &&
428
+ cat >../trace.expect <<EOF &&
429
+ node creation: 0
430
+ gitignore invalidation: 1
431
+ directory invalidation: 2
432
+ opendir: 2
433
+ EOF
434
+ test_cmp ../trace.expect ../trace
435
+ '
436
+
437
+ test_expect_success ' untracked cache correct after status' '
438
+ test-dump-untracked-cache >../actual &&
439
+ cat >../expect <<EOF &&
440
+ info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
441
+ core.excludesfile 0000000000000000000000000000000000000000
442
+ exclude_per_dir .gitignore
443
+ flags 00000006
444
+ / e6fcc8f2ee31bae321d66afd183fcb7237afae6e recurse valid
445
+ .gitignore
446
+ dtwo/
447
+ /done/ 1946f0437f90c5005533cbe1736a6451ca301714 recurse valid
448
+ five
449
+ /dthree/ 0000000000000000000000000000000000000000 recurse check_only valid
450
+ /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid
451
+ two
452
+ EOF
453
+ test_cmp ../expect ../actual
454
+ '
455
+
456
+ test_expect_success ' test sparse status again with untracked cache' '
457
+ avoid_racy &&
458
+ : >../trace &&
459
+ GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace" \
460
+ git status --porcelain >../status.actual &&
461
+ cat >../status.expect <<EOF &&
462
+ ?? .gitignore
463
+ ?? done/five
464
+ ?? dtwo/
465
+ EOF
466
+ test_cmp ../status.expect ../status.actual &&
467
+ cat >../trace.expect <<EOF &&
468
+ node creation: 0
469
+ gitignore invalidation: 0
470
+ directory invalidation: 0
471
+ opendir: 0
472
+ EOF
473
+ test_cmp ../trace.expect ../trace
474
+ '
475
+
357
476
test_done
0 commit comments