@@ -579,6 +579,45 @@ test_expect_success 'diff --cached' '
579
579
test_all_match git diff --cached
580
580
'
581
581
582
+ test_expect_success ' diff partially-staged' '
583
+ init_repos &&
584
+
585
+ git -C full-checkout config advice.sparseIndexExpanded false &&
586
+
587
+ write_script edit-contents <<-\EOF &&
588
+ echo text >>$1
589
+ EOF
590
+
591
+ # Add file within cone
592
+ test_all_match git sparse-checkout set deep &&
593
+ run_on_all ../edit-contents deep/testfile &&
594
+ test_all_match git add deep/testfile &&
595
+ run_on_all ../edit-contents deep/testfile &&
596
+
597
+ test_all_match git diff &&
598
+ test_all_match git diff --staged &&
599
+
600
+ # Add file outside cone
601
+ test_all_match git reset --hard &&
602
+ run_on_all mkdir newdirectory &&
603
+ run_on_all ../edit-contents newdirectory/testfile &&
604
+ test_all_match git sparse-checkout set newdirectory &&
605
+ test_all_match git add newdirectory/testfile &&
606
+ run_on_all ../edit-contents newdirectory/testfile &&
607
+ test_all_match git sparse-checkout set &&
608
+
609
+ test_all_match git diff &&
610
+ test_all_match git diff --staged &&
611
+
612
+ # Merge conflict outside cone
613
+ test_all_match git reset --hard &&
614
+ test_all_match git checkout merge-left &&
615
+ test_all_match test_must_fail git merge merge-right &&
616
+
617
+ test_all_match git diff &&
618
+ test_all_match git diff --staged
619
+ '
620
+
582
621
# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
583
622
# running this test with 'df-conflict-2' after 'df-conflict-1'.
584
623
test_expect_success ' diff with renames and conflicts' '
@@ -1544,6 +1583,11 @@ test_expect_success 'sparse-index is not expanded' '
1544
1583
ensure_not_expanded reset --merge update-deep &&
1545
1584
ensure_not_expanded reset --hard &&
1546
1585
1586
+ echo a test change >>sparse-index/README.md &&
1587
+ ensure_not_expanded diff &&
1588
+ git -C sparse-index add README.md &&
1589
+ ensure_not_expanded diff --staged &&
1590
+
1547
1591
ensure_not_expanded reset base -- deep/a &&
1548
1592
ensure_not_expanded reset base -- nonexistent-file &&
1549
1593
ensure_not_expanded reset deepest -- deep &&
0 commit comments