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 <vdye@github.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Victoria Dye committed
Jan 11, 2022 at 18:05 UTC
b553ef674965f41bfff4e0a2c330f9087b3cd6b7
2 files changed
+55
t/perf/p2000-sparse-operations.sh
+1
@@ -117,5 +117,6 @@ test_perf_on_all git diff
117
test_perf_on_all git diff --cached
118
test_perf_on_all git blame $SPARSE_CONE/a
119
test_perf_on_all git blame $SPARSE_CONE/f3/a
120
+test_perf_on_all git checkout-index -f --all
121
122
test_done
t/t1092-sparse-checkout-compatibility.sh
+54
@@ -755,6 +755,60 @@ test_expect_success 'cherry-pick with conflicts' '
755
test_all_match test_must_fail git cherry-pick to-cherry-pick
756
'
757
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
+
812
test_expect_success 'clean' '
813
init_repos &&
814