Sync with Git 2.46-rc1
[alt-git.git] / t / t3509-cherry-pick-merge-df.sh
blob171cc6d76b797c99638bda0d63083aecfd7a5a2d
1 #!/bin/sh
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
8 . ./test-lib.sh
10 test_expect_success 'Initialize repository' '
11 mkdir a &&
12 >a/f &&
13 git add a &&
14 git commit -m a
17 test_expect_success 'Setup rename across paths each below D/F conflicts' '
18 mkdir b &&
19 test_ln_s_add ../a b/a &&
20 git commit -m b &&
22 git checkout -b branch &&
23 rm b/a &&
24 git mv a b/a &&
25 test_ln_s_add b/a a &&
26 git commit -m swap &&
28 >f1 &&
29 git add f1 &&
30 git commit -m f1
33 test_expect_success 'Cherry-pick succeeds with rename across D/F conflicts' '
34 git reset --hard &&
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 &&
41 git rm -rf . &&
43 >empty &&
44 git add empty &&
45 git commit -m "Empty file" &&
47 git checkout -b simple &&
48 mv empty file &&
49 mkdir empty &&
50 mv file empty &&
51 git add empty/file &&
52 git commit -m "Empty file under empty dir" &&
54 echo content >newfile &&
55 git add newfile &&
56 git commit -m "New file"
59 test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (resolve)' '
60 git reset --hard &&
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)' '
66 git reset --hard &&
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' '
72 git reset --hard &&
73 git checkout --orphan mergeme &&
74 git rm -rf . &&
76 mkdir sub &&
77 mkdir othersub &&
78 echo content > sub/file &&
79 echo foo > othersub/whatever &&
80 git add -A &&
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)' '
94 git reset --hard &&
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)' '
100 git reset --hard &&
101 git checkout -q newhead^0 &&
102 git cherry-pick --strategy=recursive mergeme
105 test_done