t3507: add a testcase showing failure with sparse checkout

Recent changes in merge_content() induced a bug when merging files that are not present in the local working directory due to sparse-checkout. Add a test case to demonstrate the bug so that we can ensure the fix resolves it and to prevent future regressions. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ben Peart committed Jul 27, 2018 at 12:59 UTC 92203e6432cd77c3dfc82bd475a4c802085cffcb
1 file changed +13
t/t3507-cherry-pick-conflict.sh
+13
@@ -392,4 +392,17 @@ test_expect_success 'commit --amend -s places the sign-off at the right place' '
392 test_cmp expect actual
393 '
394
395 +test_expect_failure 'cherry-pick preserves sparse-checkout' '
396 + pristine_detach initial &&
397 + test_config core.sparseCheckout true &&
398 + test_when_finished "
399 + echo \"/*\" >.git/info/sparse-checkout
400 + git read-tree --reset -u HEAD
401 + rm .git/info/sparse-checkout" &&
402 + echo /unrelated >.git/info/sparse-checkout &&
403 + git read-tree --reset -u HEAD &&
404 + test_must_fail git cherry-pick -Xours picked>actual &&
405 + test_i18ngrep ! "Changes not staged for commit:" actual
406 +'
407 +
408 test_done