blob: 1e5b3948dfc5d28a070ba83db361163002e7c3ae [file] [log] [blame]
Alexander Gladyshf433f702010-07-09 07:10:52 -06001#!/bin/sh
2
3test_description='Test cherry-pick with directory/file conflicts'
4. ./test-lib.sh
5
Pat Thoyts899663f2011-02-03 15:31:42 +00006test_expect_success 'Initialize repository' '
Alexander Gladyshf433f702010-07-09 07:10:52 -06007 mkdir a &&
8 >a/f &&
9 git add a &&
Pat Thoyts899663f2011-02-03 15:31:42 +000010 git commit -m a
11'
Alexander Gladyshf433f702010-07-09 07:10:52 -060012
Johannes Sixt622f98e2013-06-07 22:53:32 +020013test_expect_success 'Setup rename across paths each below D/F conflicts' '
Alexander Gladyshf433f702010-07-09 07:10:52 -060014 mkdir b &&
Johannes Sixt622f98e2013-06-07 22:53:32 +020015 test_ln_s_add ../a b/a &&
Alexander Gladyshf433f702010-07-09 07:10:52 -060016 git commit -m b &&
17
18 git checkout -b branch &&
19 rm b/a &&
Johannes Sixt622f98e2013-06-07 22:53:32 +020020 git mv a b/a &&
21 test_ln_s_add b/a a &&
Alexander Gladyshf433f702010-07-09 07:10:52 -060022 git commit -m swap &&
23
24 >f1 &&
25 git add f1 &&
26 git commit -m f1
27'
28
Johannes Sixt622f98e2013-06-07 22:53:32 +020029test_expect_success 'Cherry-pick succeeds with rename across D/F conflicts' '
Alexander Gladyshf433f702010-07-09 07:10:52 -060030 git reset --hard &&
31 git checkout master^0 &&
32 git cherry-pick branch
33'
34
Elijah Newren56bfd762010-09-08 00:40:40 -060035test_expect_success 'Setup rename with file on one side matching directory name on other' '
36 git checkout --orphan nick-testcase &&
37 git rm -rf . &&
38
39 >empty &&
40 git add empty &&
41 git commit -m "Empty file" &&
42
43 git checkout -b simple &&
44 mv empty file &&
45 mkdir empty &&
46 mv file empty &&
47 git add empty/file &&
48 git commit -m "Empty file under empty dir" &&
49
50 echo content >newfile &&
51 git add newfile &&
52 git commit -m "New file"
53'
54
55test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (resolve)' '
56 git reset --hard &&
57 git checkout -q nick-testcase^0 &&
58 git cherry-pick --strategy=resolve simple
59'
60
Elijah Newren86273e52010-09-08 00:40:41 -060061test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (recursive)' '
Elijah Newren56bfd762010-09-08 00:40:40 -060062 git reset --hard &&
63 git checkout -q nick-testcase^0 &&
64 git cherry-pick --strategy=recursive simple
65'
66
67test_expect_success 'Setup rename with file on one side matching different dirname on other' '
68 git reset --hard &&
69 git checkout --orphan mergeme &&
70 git rm -rf . &&
71
72 mkdir sub &&
73 mkdir othersub &&
74 echo content > sub/file &&
75 echo foo > othersub/whatever &&
76 git add -A &&
Junio C Hamanoa316b952013-09-04 15:28:45 -070077 git commit -m "Common commit" &&
Elijah Newren56bfd762010-09-08 00:40:40 -060078
79 git rm -rf othersub &&
80 git mv sub/file othersub &&
81 git commit -m "Commit to merge" &&
82
83 git checkout -b newhead mergeme~1 &&
84 >independent-change &&
85 git add independent-change &&
86 git commit -m "Completely unrelated change"
87'
88
89test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (resolve)' '
90 git reset --hard &&
91 git checkout -q newhead^0 &&
92 git cherry-pick --strategy=resolve mergeme
93'
94
Elijah Newren86273e52010-09-08 00:40:41 -060095test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (recursive)' '
Elijah Newren56bfd762010-09-08 00:40:40 -060096 git reset --hard &&
97 git checkout -q newhead^0 &&
98 git cherry-pick --strategy=recursive mergeme
99'
100
Alexander Gladyshf433f702010-07-09 07:10:52 -0600101test_done