Skip to content

Commit 7d45ff5

Browse files
committed
checkout-index: expand sparse checkout compatibility tests
Add tests to cover basic `checkout-index` cases related to sparse checkouts: files and folder, both inside and outside of sparse checkout definition. New tests will serve as a baseline for expected behavior when integrating `checkout-index` with the sparse index. Of note is the test demonstrating the behavior of `checkout-index --all`; creating files even outside the sparse checkout definition is somewhat unintuitive, and will cause significant performance issues when run with a sparse index. The goal of later changes will be to change this default behavior and introduce a `--sparse` flag to enable populating files outside the sparse definition. Signed-off-by: Victoria Dye <[email protected]>
1 parent 0bd3c7f commit 7d45ff5

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,60 @@ test_expect_success 'cherry-pick with conflicts' '
883883
test_all_match test_must_fail git cherry-pick to-cherry-pick
884884
'
885885

886+
test_expect_success 'checkout-index inside sparse definition' '
887+
init_repos &&
888+
889+
run_on_all rm -f deep/a &&
890+
test_all_match git checkout-index -- deep/a &&
891+
test_all_match git status --porcelain=v2 &&
892+
893+
echo test >>new-a &&
894+
run_on_all cp ../new-a a &&
895+
test_all_match test_must_fail git checkout-index -- a &&
896+
test_all_match git checkout-index -f -- a &&
897+
test_all_match git status --porcelain=v2
898+
'
899+
900+
test_expect_success 'checkout-index outside sparse definition' '
901+
init_repos &&
902+
903+
# File does not exist on disk yet for sparse checkouts, so checkout-index
904+
# succeeds without -f
905+
test_sparse_match git checkout-index -- folder1/a &&
906+
test_cmp sparse-checkout/folder1/a sparse-index/folder1/a &&
907+
test_cmp sparse-checkout/folder1/a full-checkout/folder1/a &&
908+
909+
run_on_sparse rm -rf folder1 &&
910+
echo test >new-a &&
911+
run_on_sparse mkdir -p folder1 &&
912+
run_on_all cp ../new-a folder1/a &&
913+
914+
test_all_match test_must_fail git checkout-index -- folder1/a &&
915+
test_all_match git checkout-index -f -- folder1/a &&
916+
test_cmp sparse-checkout/folder1/a sparse-index/folder1/a &&
917+
test_cmp sparse-checkout/folder1/a full-checkout/folder1/a
918+
'
919+
920+
test_expect_success 'checkout-index with folders' '
921+
init_repos &&
922+
923+
# Inside checkout definition
924+
test_all_match test_must_fail git checkout-index -f -- deep/ &&
925+
926+
# Outside checkout definition
927+
test_all_match test_must_fail git checkout-index -f -- folder1/
928+
'
929+
930+
# NEEDSWORK: even in sparse checkouts, checkout-index --all will create all
931+
# files (even those outside the sparse definition) on disk. However, these files
932+
# don't appear in the percentage of tracked files in git status.
933+
test_expect_failure 'checkout-index --all' '
934+
init_repos &&
935+
936+
test_all_match git checkout-index --all &&
937+
test_sparse_match test_path_is_missing folder1
938+
'
939+
886940
test_expect_success 'clean' '
887941
init_repos &&
888942

0 commit comments

Comments
 (0)