Skip to content

Commit b553ef6

Browse files
vdyegitster
authored andcommitted
checkout-index: expand sparse checkout compatibility tests
Add tests to cover `checkout-index`, with a focus on cases interesting in a sparse checkout (e.g., files specified outside sparse checkout definition). New tests are intended to serve as a baseline for existing and/or expected behavior and performance when integrating `checkout-index` with the sparse index. Note that the test 'checkout-index --all' is marked as 'test_expect_failure', indicating that `update-index --all` will be modified in a subsequent patch to behave as the test expects. Signed-off-by: Victoria Dye <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e9e10e commit b553ef6

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

t/perf/p2000-sparse-operations.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@ test_perf_on_all git diff
117117
test_perf_on_all git diff --cached
118118
test_perf_on_all git blame $SPARSE_CONE/a
119119
test_perf_on_all git blame $SPARSE_CONE/f3/a
120+
test_perf_on_all git checkout-index -f --all
120121

121122
test_done

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,60 @@ test_expect_success 'cherry-pick with conflicts' '
755755
test_all_match test_must_fail git cherry-pick to-cherry-pick
756756
'
757757

758+
test_expect_success 'checkout-index inside sparse definition' '
759+
init_repos &&
760+
761+
run_on_all rm -f deep/a &&
762+
test_all_match git checkout-index -- deep/a &&
763+
test_all_match git status --porcelain=v2 &&
764+
765+
echo test >>new-a &&
766+
run_on_all cp ../new-a a &&
767+
test_all_match test_must_fail git checkout-index -- a &&
768+
test_all_match git checkout-index -f -- a &&
769+
test_all_match git status --porcelain=v2
770+
'
771+
772+
test_expect_success 'checkout-index outside sparse definition' '
773+
init_repos &&
774+
775+
# File does not exist on disk yet for sparse checkouts, so checkout-index
776+
# succeeds without -f
777+
test_sparse_match git checkout-index -- folder1/a &&
778+
test_cmp sparse-checkout/folder1/a sparse-index/folder1/a &&
779+
test_cmp sparse-checkout/folder1/a full-checkout/folder1/a &&
780+
781+
run_on_sparse rm -rf folder1 &&
782+
echo test >new-a &&
783+
run_on_sparse mkdir -p folder1 &&
784+
run_on_all cp ../new-a folder1/a &&
785+
786+
test_all_match test_must_fail git checkout-index -- folder1/a &&
787+
test_all_match git checkout-index -f -- folder1/a &&
788+
test_cmp sparse-checkout/folder1/a sparse-index/folder1/a &&
789+
test_cmp sparse-checkout/folder1/a full-checkout/folder1/a
790+
'
791+
792+
test_expect_success 'checkout-index with folders' '
793+
init_repos &&
794+
795+
# Inside checkout definition
796+
test_all_match test_must_fail git checkout-index -f -- deep/ &&
797+
798+
# Outside checkout definition
799+
test_all_match test_must_fail git checkout-index -f -- folder1/
800+
'
801+
802+
# NEEDSWORK: even in sparse checkouts, checkout-index --all will create all
803+
# files (even those outside the sparse definition) on disk. However, these files
804+
# don't appear in the percentage of tracked files in git status.
805+
test_expect_failure 'checkout-index --all' '
806+
init_repos &&
807+
808+
test_all_match git checkout-index --all &&
809+
test_sparse_match test_path_is_missing folder1
810+
'
811+
758812
test_expect_success 'clean' '
759813
init_repos &&
760814

0 commit comments

Comments
 (0)