@@ -417,6 +417,43 @@ test_expect_success 'diff --staged' '
417
417
test_all_match git diff --staged
418
418
'
419
419
420
+ test_expect_success ' diff partially-staged' '
421
+ init_repos &&
422
+
423
+ write_script edit-contents <<-\EOF &&
424
+ echo text >>$1
425
+ EOF
426
+
427
+ # Add file within cone
428
+ test_all_match git sparse-checkout set deep &&
429
+ run_on_all ../edit-contents deep/testfile &&
430
+ test_all_match git add deep/testfile &&
431
+ run_on_all ../edit-contents deep/testfile &&
432
+
433
+ test_all_match git diff &&
434
+ test_all_match git diff --staged &&
435
+
436
+ # Add file outside cone
437
+ test_all_match git reset --hard &&
438
+ run_on_all mkdir newdirectory &&
439
+ run_on_all ../edit-contents newdirectory/testfile &&
440
+ test_all_match git sparse-checkout set newdirectory &&
441
+ test_all_match git add newdirectory/testfile &&
442
+ run_on_all ../edit-contents newdirectory/testfile &&
443
+ test_all_match git sparse-checkout set &&
444
+
445
+ test_all_match git diff &&
446
+ test_all_match git diff --staged &&
447
+
448
+ # Merge conflict outside cone
449
+ test_all_match git reset --hard &&
450
+ test_all_match git checkout merge-left &&
451
+ test_all_match test_must_fail git merge merge-right &&
452
+
453
+ test_all_match git diff &&
454
+ test_all_match git diff --staged
455
+ '
456
+
420
457
# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
421
458
# running this test with 'df-conflict-2' after 'df-conflict-1'.
422
459
test_expect_success ' diff with renames and conflicts' '
@@ -872,6 +909,11 @@ test_expect_success 'sparse-index is not expanded' '
872
909
873
910
ensure_not_expanded reset --hard update-deep &&
874
911
912
+ echo a test change >>sparse-index/README.md &&
913
+ ensure_not_expanded diff &&
914
+ git -C sparse-index add README.md &&
915
+ ensure_not_expanded diff --staged &&
916
+
875
917
ensure_not_expanded reset base -- deep/a &&
876
918
ensure_not_expanded reset base -- nonexistent-file &&
877
919
ensure_not_expanded reset deepest -- deep &&
0 commit comments