sparse-index: loose integration with cache_tree_verify()
[git] / t / t3509-cherry-pick-merge-df.sh
1 #!/bin/sh
2
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
6
7 . ./test-lib.sh
8
9 test_expect_success 'Initialize repository' '
10         mkdir a &&
11         >a/f &&
12         git add a &&
13         git commit -m a
14 '
15
16 test_expect_success 'Setup rename across paths each below D/F conflicts' '
17         mkdir b &&
18         test_ln_s_add ../a b/a &&
19         git commit -m b &&
20
21         git checkout -b branch &&
22         rm b/a &&
23         git mv a b/a &&
24         test_ln_s_add b/a a &&
25         git commit -m swap &&
26
27         >f1 &&
28         git add f1 &&
29         git commit -m f1
30 '
31
32 test_expect_success 'Cherry-pick succeeds with rename across D/F conflicts' '
33         git reset --hard &&
34         git checkout main^0 &&
35         git cherry-pick branch
36 '
37
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
64 test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (recursive)' '
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 &&
80         git commit -m "Common commit" &&
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
98 test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (recursive)' '
99         git reset --hard &&
100         git checkout -q newhead^0 &&
101         git cherry-pick --strategy=recursive mergeme
102 '
103
104 test_done