stash: expand sparse-checkout compatibility testing

Add tests verifying expected 'git stash' behavior in 't1092-sparse-checkout-compatibility'. These cases establish the expected behavior of 'git stash' in a sparse-checkout and verify consistency both with and without a sparse index. Although no sparse index compatibility has been integrated into 'git stash' yet, the tests are all 'expect_success' - we don't want the cone-mode sparse-checkout behavior to change depending on whether it is using a sparse index or not. Therefore, we expect these tests to continue passing once sparse index is integrated with 'git stash'. Additionally, add performance test cases for 'git stash' both with and without untracked files. Note that, unlike the other tests in 'p2000-sparse-operations.sh', the tests added for 'stash' are combination operations. This is done to ensure the stash/unstash is not blocked by the modification of '$SPARSE_CONE/a' performed as part of 'test_perf_on_all'. Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Victoria Dye committed May 10, 2022 at 23:32 UTC eae937059be0ae7b4a8e6bfbb985c8c079129419
2 files changed +51
t/perf/p2000-sparse-operations.sh
+2
@@ -106,6 +106,8 @@ test_perf_on_all () {
106 }
107
108 test_perf_on_all git status
109 +test_perf_on_all 'git stash && git stash pop'
110 +test_perf_on_all 'echo >>new && git stash -u && git stash pop'
111 test_perf_on_all git add -A
112 test_perf_on_all git add .
113 test_perf_on_all git commit -a -m A
t/t1092-sparse-checkout-compatibility.sh
+49
@@ -1034,6 +1034,55 @@ test_expect_success 'cherry-pick with conflicts' '
1034 test_all_match test_must_fail git cherry-pick to-cherry-pick
1035 '
1036
1037 +test_expect_success 'stash' '
1038 + init_repos &&
1039 +
1040 + write_script edit-contents <<-\EOF &&
1041 + echo text >>$1
1042 + EOF
1043 +
1044 + # Stash a sparse directory (folder1)
1045 + test_all_match git checkout -b test-branch rename-base &&
1046 + test_all_match git reset --soft rename-out-to-out &&
1047 + test_all_match git stash &&
1048 + test_all_match git status --porcelain=v2 &&
1049 +
1050 + # Apply the sparse directory stash without reinstating the index
1051 + test_all_match git stash apply -q &&
1052 + test_all_match git status --porcelain=v2 &&
1053 +
1054 + # Reset to state where stash can be applied
1055 + test_sparse_match git sparse-checkout reapply &&
1056 + test_all_match git reset --hard rename-out-to-out &&
1057 +
1058 + # Apply the sparse directory stash *with* reinstating the index
1059 + test_all_match git stash apply --index -q &&
1060 + test_all_match git status --porcelain=v2 &&
1061 +
1062 + # Reset to state where we will get a conflict applying the stash
1063 + test_sparse_match git sparse-checkout reapply &&
1064 + test_all_match git reset --hard update-folder1 &&
1065 +
1066 + # Apply the sparse directory stash with conflicts
1067 + test_all_match test_must_fail git stash apply --index -q &&
1068 + test_all_match test_must_fail git stash apply -q &&
1069 + test_all_match git status --porcelain=v2 &&
1070 +
1071 + # Reset to base branch
1072 + test_sparse_match git sparse-checkout reapply &&
1073 + test_all_match git reset --hard base &&
1074 +
1075 + # Stash & unstash an untracked file outside of the sparse checkout
1076 + # definition.
1077 + run_on_sparse mkdir -p folder1 &&
1078 + run_on_all ../edit-contents folder1/new &&
1079 + test_all_match git stash -u &&
1080 + test_all_match git status --porcelain=v2 &&
1081 +
1082 + test_all_match git stash pop -q &&
1083 + test_all_match git status --porcelain=v2
1084 +'
1085 +
1086 test_expect_success 'checkout-index inside sparse definition' '
1087 init_repos &&
1088