@@ -518,6 +518,43 @@ test_expect_success 'diff --cached' '
518
518
test_all_match git diff --cached
519
519
'
520
520
521
+ test_expect_success ' diff partially-staged' '
522
+ init_repos &&
523
+
524
+ write_script edit-contents <<-\EOF &&
525
+ echo text >>$1
526
+ EOF
527
+
528
+ # Add file within cone
529
+ test_all_match git sparse-checkout set deep &&
530
+ run_on_all ../edit-contents deep/testfile &&
531
+ test_all_match git add deep/testfile &&
532
+ run_on_all ../edit-contents deep/testfile &&
533
+
534
+ test_all_match git diff &&
535
+ test_all_match git diff --staged &&
536
+
537
+ # Add file outside cone
538
+ test_all_match git reset --hard &&
539
+ run_on_all mkdir newdirectory &&
540
+ run_on_all ../edit-contents newdirectory/testfile &&
541
+ test_all_match git sparse-checkout set newdirectory &&
542
+ test_all_match git add newdirectory/testfile &&
543
+ run_on_all ../edit-contents newdirectory/testfile &&
544
+ test_all_match git sparse-checkout set &&
545
+
546
+ test_all_match git diff &&
547
+ test_all_match git diff --staged &&
548
+
549
+ # Merge conflict outside cone
550
+ test_all_match git reset --hard &&
551
+ test_all_match git checkout merge-left &&
552
+ test_all_match test_must_fail git merge merge-right &&
553
+
554
+ test_all_match git diff &&
555
+ test_all_match git diff --staged
556
+ '
557
+
521
558
# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
522
559
# running this test with 'df-conflict-2' after 'df-conflict-1'.
523
560
test_expect_success ' diff with renames and conflicts' '
@@ -1453,6 +1490,11 @@ test_expect_success 'sparse-index is not expanded' '
1453
1490
ensure_not_expanded reset --merge update-deep &&
1454
1491
ensure_not_expanded reset --hard &&
1455
1492
1493
+ echo a test change >>sparse-index/README.md &&
1494
+ ensure_not_expanded diff &&
1495
+ git -C sparse-index add README.md &&
1496
+ ensure_not_expanded diff --staged &&
1497
+
1456
1498
ensure_not_expanded reset base -- deep/a &&
1457
1499
ensure_not_expanded reset base -- nonexistent-file &&
1458
1500
ensure_not_expanded reset deepest -- deep &&
0 commit comments