Skip to content

Commit 506b545

Browse files
ldenningtondscho
authored andcommitted
diff(sparse-index): verify with partially-sparse
This verifies that `diff` and `diff --staged` behave the same in sparse index repositories in the following partially-staged scenarios (i.e. the index, HEAD, and working directory differ at a given path): 1. Path is within sparse-checkout cone. 2. Path is outside sparse-checkout cone. 3. A merge conflict exists for paths outside sparse-checkout cone. Signed-off-by: Lessley Dennington <[email protected]>
1 parent 967a08a commit 506b545

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

+42
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,43 @@ test_expect_success 'diff --cached' '
518518
test_all_match git diff --cached
519519
'
520520

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+
521558
# NEEDSWORK: sparse-checkout behaves differently from full-checkout when
522559
# running this test with 'df-conflict-2' after 'df-conflict-1'.
523560
test_expect_success 'diff with renames and conflicts' '
@@ -1453,6 +1490,11 @@ test_expect_success 'sparse-index is not expanded' '
14531490
ensure_not_expanded reset --merge update-deep &&
14541491
ensure_not_expanded reset --hard &&
14551492
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+
14561498
ensure_not_expanded reset base -- deep/a &&
14571499
ensure_not_expanded reset base -- nonexistent-file &&
14581500
ensure_not_expanded reset deepest -- deep &&

0 commit comments

Comments
 (0)