]>
Commit | Line | Data |
---|---|---|
f433f705 AG |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test cherry-pick with directory/file conflicts' | |
cbc75a12 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
f433f705 AG |
7 | . ./test-lib.sh |
8 | ||
899663f8 | 9 | test_expect_success 'Initialize repository' ' |
f433f705 AG |
10 | mkdir a && |
11 | >a/f && | |
12 | git add a && | |
899663f8 PT |
13 | git commit -m a |
14 | ' | |
f433f705 | 15 | |
622f98e2 | 16 | test_expect_success 'Setup rename across paths each below D/F conflicts' ' |
f433f705 | 17 | mkdir b && |
622f98e2 | 18 | test_ln_s_add ../a b/a && |
f433f705 AG |
19 | git commit -m b && |
20 | ||
21 | git checkout -b branch && | |
22 | rm b/a && | |
622f98e2 JS |
23 | git mv a b/a && |
24 | test_ln_s_add b/a a && | |
f433f705 AG |
25 | git commit -m swap && |
26 | ||
27 | >f1 && | |
28 | git add f1 && | |
29 | git commit -m f1 | |
30 | ' | |
31 | ||
622f98e2 | 32 | test_expect_success 'Cherry-pick succeeds with rename across D/F conflicts' ' |
f433f705 | 33 | git reset --hard && |
cbc75a12 | 34 | git checkout main^0 && |
f433f705 AG |
35 | git cherry-pick branch |
36 | ' | |
37 | ||
56bfd762 EN |
38 | test_expect_success 'Setup rename with file on one side matching directory name on other' ' |
39 | git checkout --orphan nick-testcase && | |
40 | git rm -rf . && | |
41 | ||
42 | >empty && | |
43 | git add empty && | |
44 | git commit -m "Empty file" && | |
45 | ||
46 | git checkout -b simple && | |
47 | mv empty file && | |
48 | mkdir empty && | |
49 | mv file empty && | |
50 | git add empty/file && | |
51 | git commit -m "Empty file under empty dir" && | |
52 | ||
53 | echo content >newfile && | |
54 | git add newfile && | |
55 | git commit -m "New file" | |
56 | ' | |
57 | ||
58 | test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (resolve)' ' | |
59 | git reset --hard && | |
60 | git checkout -q nick-testcase^0 && | |
61 | git cherry-pick --strategy=resolve simple | |
62 | ' | |
63 | ||
86273e57 | 64 | test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (recursive)' ' |
56bfd762 EN |
65 | git reset --hard && |
66 | git checkout -q nick-testcase^0 && | |
67 | git cherry-pick --strategy=recursive simple | |
68 | ' | |
69 | ||
70 | test_expect_success 'Setup rename with file on one side matching different dirname on other' ' | |
71 | git reset --hard && | |
72 | git checkout --orphan mergeme && | |
73 | git rm -rf . && | |
74 | ||
75 | mkdir sub && | |
76 | mkdir othersub && | |
77 | echo content > sub/file && | |
78 | echo foo > othersub/whatever && | |
79 | git add -A && | |
a316b954 | 80 | git commit -m "Common commit" && |
56bfd762 EN |
81 | |
82 | git rm -rf othersub && | |
83 | git mv sub/file othersub && | |
84 | git commit -m "Commit to merge" && | |
85 | ||
86 | git checkout -b newhead mergeme~1 && | |
87 | >independent-change && | |
88 | git add independent-change && | |
89 | git commit -m "Completely unrelated change" | |
90 | ' | |
91 | ||
92 | test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (resolve)' ' | |
93 | git reset --hard && | |
94 | git checkout -q newhead^0 && | |
95 | git cherry-pick --strategy=resolve mergeme | |
96 | ' | |
97 | ||
86273e57 | 98 | test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (recursive)' ' |
56bfd762 EN |
99 | git reset --hard && |
100 | git checkout -q newhead^0 && | |
101 | git cherry-pick --strategy=recursive mergeme | |
102 | ' | |
103 | ||
f433f705 | 104 | test_done |