3 test_description
='Test cherry-pick with directory/file conflicts'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK
=true
10 test_expect_success
'Initialize repository' '
17 test_expect_success
'Setup rename across paths each below D/F conflicts' '
19 test_ln_s_add ../a b/a &&
22 git checkout -b branch &&
25 test_ln_s_add b/a a &&
33 test_expect_success
'Cherry-pick succeeds with rename across D/F conflicts' '
35 git checkout main^0 &&
36 git cherry-pick branch
39 test_expect_success
'Setup rename with file on one side matching directory name on other' '
40 git checkout --orphan nick-testcase &&
45 git commit -m "Empty file" &&
47 git checkout -b simple &&
52 git commit -m "Empty file under empty dir" &&
54 echo content >newfile &&
56 git commit -m "New file"
59 test_expect_success
'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (resolve)' '
61 git checkout -q nick-testcase^0 &&
62 git cherry-pick --strategy=resolve simple
65 test_expect_success
'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (recursive)' '
67 git checkout -q nick-testcase^0 &&
68 git cherry-pick --strategy=recursive simple
71 test_expect_success
'Setup rename with file on one side matching different dirname on other' '
73 git checkout --orphan mergeme &&
78 echo content > sub/file &&
79 echo foo > othersub/whatever &&
81 git commit -m "Common commit" &&
83 git rm -rf othersub &&
84 git mv sub/file othersub &&
85 git commit -m "Commit to merge" &&
87 git checkout -b newhead mergeme~1 &&
88 >independent-change &&
89 git add independent-change &&
90 git commit -m "Completely unrelated change"
93 test_expect_success
'Cherry-pick with rename to different D/F conflict succeeds (resolve)' '
95 git checkout -q newhead^0 &&
96 git cherry-pick --strategy=resolve mergeme
99 test_expect_success
'Cherry-pick with rename to different D/F conflict succeeds (recursive)' '
101 git checkout -q newhead^0 &&
102 git cherry-pick --strategy=recursive mergeme