@@ -488,6 +488,43 @@ test_expect_success 'diff --cached' '
488
488
test_all_match git diff --cached
489
489
'
490
490
491
+ test_expect_success ' diff partially-staged' '
492
+ init_repos &&
493
+
494
+ write_script edit-contents <<-\EOF &&
495
+ echo text >>$1
496
+ EOF
497
+
498
+ # Add file within cone
499
+ test_all_match git sparse-checkout set deep &&
500
+ run_on_all ../edit-contents deep/testfile &&
501
+ test_all_match git add deep/testfile &&
502
+ run_on_all ../edit-contents deep/testfile &&
503
+
504
+ test_all_match git diff &&
505
+ test_all_match git diff --staged &&
506
+
507
+ # Add file outside cone
508
+ test_all_match git reset --hard &&
509
+ run_on_all mkdir newdirectory &&
510
+ run_on_all ../edit-contents newdirectory/testfile &&
511
+ test_all_match git sparse-checkout set newdirectory &&
512
+ test_all_match git add newdirectory/testfile &&
513
+ run_on_all ../edit-contents newdirectory/testfile &&
514
+ test_all_match git sparse-checkout set &&
515
+
516
+ test_all_match git diff &&
517
+ test_all_match git diff --staged &&
518
+
519
+ # Merge conflict outside cone
520
+ test_all_match git reset --hard &&
521
+ test_all_match git checkout merge-left &&
522
+ test_all_match test_must_fail git merge merge-right &&
523
+
524
+ test_all_match git diff &&
525
+ test_all_match git diff --staged
526
+ '
527
+
491
528
# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
492
529
# running this test with 'df-conflict-2' after 'df-conflict-1'.
493
530
test_expect_success ' diff with renames and conflicts' '
@@ -1391,6 +1428,11 @@ test_expect_success 'sparse-index is not expanded' '
1391
1428
ensure_not_expanded reset --merge update-deep &&
1392
1429
ensure_not_expanded reset --hard &&
1393
1430
1431
+ echo a test change >>sparse-index/README.md &&
1432
+ ensure_not_expanded diff &&
1433
+ git -C sparse-index add README.md &&
1434
+ ensure_not_expanded diff --staged &&
1435
+
1394
1436
ensure_not_expanded reset base -- deep/a &&
1395
1437
ensure_not_expanded reset base -- nonexistent-file &&
1396
1438
ensure_not_expanded reset deepest -- deep &&
0 commit comments