Skip to content

Commit d2ba3df

Browse files
ldenningtondscho
authored andcommitted
Merge pull request #419 from ldennington/sparse-index-diff
diff: enable and test the sparse index
2 parents b3c5297 + 6ae1b53 commit d2ba3df

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
@@ -537,6 +537,45 @@ test_expect_success 'diff --cached' '
537537
test_all_match git diff --cached
538538
'
539539

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+
540579
# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
541580
# running this test with 'df-conflict-2' after 'df-conflict-1'.
542581
test_expect_success 'diff with renames and conflicts' '
@@ -1472,6 +1511,11 @@ test_expect_success 'sparse-index is not expanded' '
14721511
ensure_not_expanded reset --merge update-deep &&
14731512
ensure_not_expanded reset --hard &&
14741513
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+
14751519
ensure_not_expanded reset base -- deep/a &&
14761520
ensure_not_expanded reset base -- nonexistent-file &&
14771521
ensure_not_expanded reset deepest -- deep &&

0 commit comments

Comments
 (0)