@@ -428,6 +428,43 @@ test_expect_success 'diff --cached' '
428428 test_all_match git diff --cached
429429'
430430
431+ test_expect_success ' diff partially-staged' '
432+ init_repos &&
433+
434+ write_script edit-contents <<-\EOF &&
435+ echo text >>$1
436+ EOF
437+
438+ # Add file within cone
439+ test_all_match git sparse-checkout set deep &&
440+ run_on_all ../edit-contents deep/testfile &&
441+ test_all_match git add deep/testfile &&
442+ run_on_all ../edit-contents deep/testfile &&
443+
444+ test_all_match git diff &&
445+ test_all_match git diff --staged &&
446+
447+ # Add file outside cone
448+ test_all_match git reset --hard &&
449+ run_on_all mkdir newdirectory &&
450+ run_on_all ../edit-contents newdirectory/testfile &&
451+ test_all_match git sparse-checkout set newdirectory &&
452+ test_all_match git add newdirectory/testfile &&
453+ run_on_all ../edit-contents newdirectory/testfile &&
454+ test_all_match git sparse-checkout set &&
455+
456+ test_all_match git diff &&
457+ test_all_match git diff --staged &&
458+
459+ # Merge conflict outside cone
460+ test_all_match git reset --hard &&
461+ test_all_match git checkout merge-left &&
462+ test_all_match test_must_fail git merge merge-right &&
463+
464+ test_all_match git diff &&
465+ test_all_match git diff --staged
466+ '
467+
431468# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
432469# running this test with 'df-conflict-2' after 'df-conflict-1'.
433470test_expect_success ' diff with renames and conflicts' '
@@ -1018,6 +1055,11 @@ test_expect_success 'sparse-index is not expanded' '
10181055 ensure_not_expanded reset --merge update-deep &&
10191056 ensure_not_expanded reset --hard &&
10201057
1058+ echo a test change >>sparse-index/README.md &&
1059+ ensure_not_expanded diff &&
1060+ git -C sparse-index add README.md &&
1061+ ensure_not_expanded diff --staged &&
1062+
10211063 ensure_not_expanded reset base -- deep/a &&
10221064 ensure_not_expanded reset base -- nonexistent-file &&
10231065 ensure_not_expanded reset deepest -- deep &&
0 commit comments