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
9 test_expect_success 'Initialize repository' '
16 test_expect_success 'Setup rename across paths each below D/F conflicts' '
18 test_ln_s_add ../a b/a &&
21 git checkout -b branch &&
24 test_ln_s_add b/a a &&
32 test_expect_success 'Cherry-pick succeeds with rename across D/F conflicts' '
34 git checkout main^0 &&
35 git cherry-pick branch
38 test_expect_success 'Setup rename with file on one side matching directory name on other' '
39 git checkout --orphan nick-testcase &&
44 git commit -m "Empty file" &&
46 git checkout -b simple &&
51 git commit -m "Empty file under empty dir" &&
53 echo content >newfile &&
55 git commit -m "New file"
58 test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (resolve)' '
60 git checkout -q nick-testcase^0 &&
61 git cherry-pick --strategy=resolve simple
64 test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (recursive)' '
66 git checkout -q nick-testcase^0 &&
67 git cherry-pick --strategy=recursive simple
70 test_expect_success 'Setup rename with file on one side matching different dirname on other' '
72 git checkout --orphan mergeme &&
77 echo content > sub/file &&
78 echo foo > othersub/whatever &&
80 git commit -m "Common commit" &&
82 git rm -rf othersub &&
83 git mv sub/file othersub &&
84 git commit -m "Commit to merge" &&
86 git checkout -b newhead mergeme~1 &&
87 >independent-change &&
88 git add independent-change &&
89 git commit -m "Completely unrelated change"
92 test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (resolve)' '
94 git checkout -q newhead^0 &&
95 git cherry-pick --strategy=resolve mergeme
98 test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (recursive)' '
100 git checkout -q newhead^0 &&
101 git cherry-pick --strategy=recursive mergeme