Git fork

t: expand tests around sparse merges and clean

With the current implementation of 'git sparse-checkout clean', we
notice that a file that was in a conflicted state does not get cleaned
up because of some internal details around the SKIP_WORKTREE bit.

This test is documenting the current behavior before we update it in the
following change.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Derrick Stolee and committed by
Junio C Hamano
592d2a93 66c11bd4

+34 -22
+34 -22
t/t1091-sparse-checkout-builtin.sh
··· 1183 1183 test_must_be_empty out 1184 1184 ' 1185 1185 1186 - test_expect_success 'clean with merge conflict status' ' 1187 - git clone repo clean-merge && 1186 + test_expect_success 'sparse-checkout operations with merge conflicts' ' 1187 + git clone repo merge && 1188 1188 1189 - echo dirty >clean-merge/deep/deeper2/a && 1190 - touch clean-merge/folder2/extra && 1189 + ( 1190 + cd merge && 1191 + mkdir -p folder1/even/more/dirs && 1192 + echo base >folder1/even/more/dirs/file && 1193 + git add folder1 && 1194 + git commit -m "base" && 1191 1195 1192 - cat >input <<-EOF && 1193 - 0 $ZERO_OID folder1/a 1194 - 100644 $(git -C clean-merge rev-parse HEAD:folder1/a) 1 folder1/a 1195 - EOF 1196 - git -C clean-merge update-index --index-info <input && 1196 + git checkout -b right&& 1197 + echo right >folder1/even/more/dirs/file && 1198 + git commit -a -m "right" && 1197 1199 1198 - git -C clean-merge sparse-checkout set deep/deeper1 && 1200 + git checkout -b left HEAD~1 && 1201 + echo left >folder1/even/more/dirs/file && 1202 + git commit -a -m "left" && 1199 1203 1200 - test_must_fail git -C clean-merge sparse-checkout clean -f 2>err && 1201 - grep "failed to convert index to a sparse index" err && 1204 + git checkout -b merge && 1205 + git sparse-checkout set deep/deeper1 && 1202 1206 1203 - mkdir -p clean-merge/folder1/ && 1204 - echo merged >clean-merge/folder1/a && 1205 - git -C clean-merge add --sparse folder1/a && 1207 + test_must_fail git merge -m "will-conflict" right && 1206 1208 1207 - # deletes folder2/ but leaves staged change in folder1 1208 - # and dirty change in deep/deeper2/ 1209 - cat >expect <<-\EOF && 1210 - Removing folder2/ 1211 - EOF 1209 + test_must_fail git sparse-checkout clean -f 2>err && 1210 + grep "failed to convert index to a sparse index" err && 1212 1211 1213 - git -C clean-merge sparse-checkout clean -f >out && 1214 - test_cmp expect out 1212 + echo merged >folder1/even/more/dirs/file && 1213 + git add --sparse folder1 && 1214 + git merge --continue && 1215 + 1216 + test_path_exists folder1/even/more/dirs/file && 1217 + 1218 + # clean does not remove the file, because the 1219 + # SKIP_WORKTREE bit was not cleared by the merge command. 1220 + git sparse-checkout clean -f >out && 1221 + test_line_count = 0 out && 1222 + test_path_exists folder1/even/more/dirs/file && 1223 + 1224 + git sparse-checkout reapply && 1225 + test_path_is_missing folder1 1226 + ) 1215 1227 ' 1216 1228 1217 1229 test_done