Skip to content

Commit 4ea711d

Browse files
ldenningtondscho
authored andcommitted
Merge pull request #419 from ldennington/sparse-index-diff
diff: enable and test the sparse index
2 parents 8093105 + 265f2d4 commit 4ea711d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,45 @@ test_expect_success 'diff --cached' '
579579
test_all_match git diff --cached
580580
'
581581

582+
test_expect_success 'diff partially-staged' '
583+
init_repos &&
584+
585+
git -C full-checkout config advice.sparseIndexExpanded false &&
586+
587+
write_script edit-contents <<-\EOF &&
588+
echo text >>$1
589+
EOF
590+
591+
# Add file within cone
592+
test_all_match git sparse-checkout set deep &&
593+
run_on_all ../edit-contents deep/testfile &&
594+
test_all_match git add deep/testfile &&
595+
run_on_all ../edit-contents deep/testfile &&
596+
597+
test_all_match git diff &&
598+
test_all_match git diff --staged &&
599+
600+
# Add file outside cone
601+
test_all_match git reset --hard &&
602+
run_on_all mkdir newdirectory &&
603+
run_on_all ../edit-contents newdirectory/testfile &&
604+
test_all_match git sparse-checkout set newdirectory &&
605+
test_all_match git add newdirectory/testfile &&
606+
run_on_all ../edit-contents newdirectory/testfile &&
607+
test_all_match git sparse-checkout set &&
608+
609+
test_all_match git diff &&
610+
test_all_match git diff --staged &&
611+
612+
# Merge conflict outside cone
613+
test_all_match git reset --hard &&
614+
test_all_match git checkout merge-left &&
615+
test_all_match test_must_fail git merge merge-right &&
616+
617+
test_all_match git diff &&
618+
test_all_match git diff --staged
619+
'
620+
582621
# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
583622
# running this test with 'df-conflict-2' after 'df-conflict-1'.
584623
test_expect_success 'diff with renames and conflicts' '
@@ -1544,6 +1583,11 @@ test_expect_success 'sparse-index is not expanded' '
15441583
ensure_not_expanded reset --merge update-deep &&
15451584
ensure_not_expanded reset --hard &&
15461585
1586+
echo a test change >>sparse-index/README.md &&
1587+
ensure_not_expanded diff &&
1588+
git -C sparse-index add README.md &&
1589+
ensure_not_expanded diff --staged &&
1590+
15471591
ensure_not_expanded reset base -- deep/a &&
15481592
ensure_not_expanded reset base -- nonexistent-file &&
15491593
ensure_not_expanded reset deepest -- deep &&

0 commit comments

Comments
 (0)