@@ -537,6 +537,45 @@ test_expect_success 'diff --cached' '
537
537
test_all_match git diff --cached
538
538
'
539
539
540
+ test_expect_success ' diff partially-staged' '
541
+ init_repos &&
542
+
543
+ git -C full-checkout config advice.sparseIndexExpanded false &&
544
+
545
+ write_script edit-contents <<-\EOF &&
546
+ echo text >>$1
547
+ EOF
548
+
549
+ # Add file within cone
550
+ test_all_match git sparse-checkout set deep &&
551
+ run_on_all ../edit-contents deep/testfile &&
552
+ test_all_match git add deep/testfile &&
553
+ run_on_all ../edit-contents deep/testfile &&
554
+
555
+ test_all_match git diff &&
556
+ test_all_match git diff --staged &&
557
+
558
+ # Add file outside cone
559
+ test_all_match git reset --hard &&
560
+ run_on_all mkdir newdirectory &&
561
+ run_on_all ../edit-contents newdirectory/testfile &&
562
+ test_all_match git sparse-checkout set newdirectory &&
563
+ test_all_match git add newdirectory/testfile &&
564
+ run_on_all ../edit-contents newdirectory/testfile &&
565
+ test_all_match git sparse-checkout set &&
566
+
567
+ test_all_match git diff &&
568
+ test_all_match git diff --staged &&
569
+
570
+ # Merge conflict outside cone
571
+ test_all_match git reset --hard &&
572
+ test_all_match git checkout merge-left &&
573
+ test_all_match test_must_fail git merge merge-right &&
574
+
575
+ test_all_match git diff &&
576
+ test_all_match git diff --staged
577
+ '
578
+
540
579
# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
541
580
# running this test with 'df-conflict-2' after 'df-conflict-1'.
542
581
test_expect_success ' diff with renames and conflicts' '
@@ -1472,6 +1511,11 @@ test_expect_success 'sparse-index is not expanded' '
1472
1511
ensure_not_expanded reset --merge update-deep &&
1473
1512
ensure_not_expanded reset --hard &&
1474
1513
1514
+ echo a test change >>sparse-index/README.md &&
1515
+ ensure_not_expanded diff &&
1516
+ git -C sparse-index add README.md &&
1517
+ ensure_not_expanded diff --staged &&
1518
+
1475
1519
ensure_not_expanded reset base -- deep/a &&
1476
1520
ensure_not_expanded reset base -- nonexistent-file &&
1477
1521
ensure_not_expanded reset deepest -- deep &&
0 commit comments