3 test_description
='merging with submodules'
17 test_expect_success setup
'
22 echo original > file &&
25 git commit -m sub-root) &&
30 git checkout -b a master &&
35 git commit -m sub-a) &&
40 git checkout -b b master &&
45 git commit -m sub-b) &&
50 git checkout -b c a &&
51 git merge -s ours b &&
53 git checkout -b d b &&
65 # a in the main repository records to sub-a in the submodule and
66 # analogous b and c. d should be automatically found by merging c into
67 # b in the main repository.
68 test_expect_success
'setup for merge search' '
75 echo "file-a" > file-a &&
77 git commit -m "sub-a" &&
85 git checkout -b sub-b &&
86 echo "file-b" > file-b &&
88 git commit -m "sub-b") &&
89 git commit -a -m "b" &&
91 git checkout -b c a &&
93 git checkout -b sub-c sub-a &&
94 echo "file-c" > file-c &&
96 git commit -m "sub-c") &&
97 git commit -a -m "c" &&
99 git checkout -b d a &&
101 git checkout -b sub-d sub-b &&
103 git commit -a -m "d" &&
108 test_expect_success
'merge with one side as a fast-forward of the other' '
110 git checkout -b test-forward b &&
112 git ls-tree test-forward sub | cut -f1 | cut -f3 -d" " > actual &&
114 git rev-parse sub-d > ../expect) &&
115 test_cmp actual expect)
118 test_expect_success
'merging should conflict for non fast-forward' '
120 git checkout -b test-nonforward b &&
122 git rev-parse sub-d > ../expect) &&
123 test_must_fail git merge c 2> actual &&
124 grep $(cat expect) actual > /dev/null &&
128 test_expect_success
'merging should fail for ambiguous common parent' '
130 git checkout -b test-ambiguous b &&
132 git checkout -b ambiguous sub-b &&
134 git rev-parse sub-d > ../expect1 &&
135 git rev-parse ambiguous > ../expect2) &&
136 test_must_fail git merge c 2> actual &&
137 grep $(cat expect1) actual > /dev/null &&
138 grep $(cat expect2) actual > /dev/null &&
143 # in a situation like this
147 # sub-a --- sub-b --- sub-d
157 # A merge between e and f should fail because one of the submodule
158 # commits (sub-a) does not descend from the submodule merge-base (sub-b).
160 test_expect_success
'merging should fail for changes that are backwards' '
162 git checkout -b bb a &&
164 git checkout sub-b) &&
165 git commit -a -m "bb" &&
167 git checkout -b e bb &&
169 git checkout sub-a) &&
170 git commit -a -m "e" &&
172 git checkout -b f bb &&
174 git checkout sub-d) &&
175 git commit -a -m "f" &&
177 git checkout -b test-backward e &&
178 test_must_fail git merge f &&
182 test_expect_success
'merging with a modify/modify conflict between merge bases' '
184 git reset --hard HEAD &&
185 git checkout -b test2 c &&