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" &&
107 test_expect_success 'merge with one side as a fast-forward of the other' '
109 git checkout -b test-forward b &&
111 git ls-tree test-forward sub | cut -f1 | cut -f3 -d" " > actual &&
113 git rev-parse sub-d > ../expect) &&
114 test_cmp actual expect)
117 test_expect_success 'merging should conflict for non fast-forward' '
119 git checkout -b test-nonforward b &&
121 git rev-parse sub-d > ../expect) &&
122 test_must_fail git merge c 2> actual &&
123 grep $(cat expect) actual > /dev/null &&
127 test_expect_success 'merging should fail for ambiguous common parent' '
129 git checkout -b test-ambiguous b &&
131 git checkout -b ambiguous sub-b &&
133 git rev-parse sub-d > ../expect1 &&
134 git rev-parse ambiguous > ../expect2) &&
135 test_must_fail git merge c 2> actual &&
136 grep $(cat expect1) actual > /dev/null &&
137 grep $(cat expect2) actual > /dev/null &&
141 # in a situation like this
145 # sub-a --- sub-b --- sub-d
155 # A merge between e and f should fail because one of the submodule
156 # commits (sub-a) does not descend from the submodule merge-base (sub-b).
158 test_expect_success 'merging should fail for changes that are backwards' '
160 git checkout -b bb a &&
162 git checkout sub-b) &&
163 git commit -a -m "bb" &&
165 git checkout -b e bb &&
167 git checkout sub-a) &&
168 git commit -a -m "e" &&
170 git checkout -b f bb &&
172 git checkout sub-d) &&
173 git commit -a -m "f" &&
175 git checkout -b test-backward e &&
176 test_must_fail git merge f)
179 test_expect_success 'merging with a modify/modify conflict between merge bases' '
180 git reset --hard HEAD &&
181 git checkout -b test2 c &&