@@ -387,6 +387,39 @@ test_expect_success 'diff --staged' '
387387 test_all_match git diff --staged
388388'
389389
390+ test_expect_success ' diff partially-staged' '
391+ init_repos &&
392+
393+ # Add file within cone
394+ test_all_match git sparse-checkout set deep &&
395+ run_on_all ' echo > deep/testfile' &&
396+ test_all_match git add deep/testfile &&
397+ run_on_all ' echo a new line >> deep/testfile' &&
398+
399+ test_all_match git diff &&
400+ test_all_match git diff --staged &&
401+
402+ # Add file outside cone
403+ test_all_match git reset --hard &&
404+ run_on_all mkdir newdirectory &&
405+ run_on_all ' echo > newdirectory/testfile' &&
406+ test_all_match git sparse-checkout set newdirectory &&
407+ test_all_match git add newdirectory/testfile &&
408+ run_on_all ' echo a new line >> newdirectory/testfile' &&
409+ test_all_match git sparse-checkout set &&
410+
411+ test_all_match git diff &&
412+ test_all_match git diff --staged &&
413+
414+ # Merge conflict outside cone
415+ test_all_match git reset --hard &&
416+ test_all_match git checkout merge-left &&
417+ test_all_match test_must_fail git merge merge-right &&
418+
419+ test_all_match git diff &&
420+ test_all_match git diff --staged
421+ '
422+
390423# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
391424# running this test with 'df-conflict-2' after 'df-conflict-1'.
392425test_expect_success ' diff with renames and conflicts' '
@@ -822,6 +855,12 @@ test_expect_success 'sparse-index is not expanded' '
822855 ensure_not_expanded reset base -- folder1 &&
823856
824857 ensure_not_expanded reset --hard update-deep &&
858+
859+ echo a test change >>sparse-index/README.md &&
860+ ensure_not_expanded diff &&
861+ git -C sparse-index add README.md &&
862+ ensure_not_expanded diff --staged &&
863+
825864 ensure_not_expanded checkout -f update-deep &&
826865 (
827866 sane_unset GIT_TEST_MERGE_ALGORITHM &&
0 commit comments