@@ -579,6 +579,45 @@ test_expect_success 'diff --cached' '
579579 test_all_match git diff --cached
580580'
581581
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+
582621# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
583622# running this test with 'df-conflict-2' after 'df-conflict-1'.
584623test_expect_success ' diff with renames and conflicts' '
@@ -1546,6 +1585,11 @@ test_expect_success 'sparse-index is not expanded' '
15461585 ensure_not_expanded reset --merge update-deep &&
15471586 ensure_not_expanded reset --hard &&
15481587
1588+ echo a test change >>sparse-index/README.md &&
1589+ ensure_not_expanded diff &&
1590+ git -C sparse-index add README.md &&
1591+ ensure_not_expanded diff --staged &&
1592+
15491593 ensure_not_expanded reset base -- deep/a &&
15501594 ensure_not_expanded reset base -- nonexistent-file &&
15511595 ensure_not_expanded reset deepest -- deep &&
0 commit comments