3 # Copyright (c) 2006, Junio C Hamano
6 test_description='fmt-merge-msg test'
10 test_expect_success setup '
14 git commit -m "Initial" &&
22 git commit -a -m "Second" &&
24 git checkout -b left &&
28 git commit -a -m "Common #1" &&
32 git commit -a -m "Common #2" &&
38 git commit -a -m "Left #3" &&
42 git commit -a -m "Left #4" &&
46 git commit -a -m "Left #5" &&
54 git commit -a -m "Right #3" &&
59 git commit -a -m "Right #4" &&
63 git commit -a -m "Right #5" &&
65 git checkout -b long &&
78 test_expect_success 'message for merging local branch' '
79 echo "Merge branch ${apos}left${apos}" >expected &&
81 git checkout master &&
84 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
85 test_cmp expected actual
88 test_expect_success 'message for merging external branch' '
89 echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
91 git checkout master &&
92 git fetch "$(pwd)" left &&
94 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
95 test_cmp expected actual
98 test_expect_success '[merge] summary/log configuration' '
99 cat >expected <<-EOF &&
100 Merge branch ${apos}left${apos}
110 git config merge.log true &&
111 test_might_fail git config --unset-all merge.summary &&
113 git checkout master &&
117 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
119 test_might_fail git config --unset-all merge.log &&
120 git config merge.summary true &&
122 git checkout master &&
126 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
128 test_cmp expected actual1 &&
129 test_cmp expected actual2
132 test_expect_success 'fmt-merge-msg -m' '
133 echo "Sync with left" >expected &&
134 cat >expected.log <<-EOF &&
137 * ${apos}left${apos} of $(pwd):
145 test_might_fail git config --unset merge.log &&
146 test_might_fail git config --unset merge.summary &&
147 git checkout master &&
148 git fetch "$(pwd)" left &&
149 git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
150 git fmt-merge-msg --log -m "Sync with left" \
151 <.git/FETCH_HEAD >actual.log &&
152 git config merge.log true &&
153 git fmt-merge-msg -m "Sync with left" \
154 <.git/FETCH_HEAD >actual.log-config &&
155 git fmt-merge-msg --no-log -m "Sync with left" \
156 <.git/FETCH_HEAD >actual.nolog &&
158 test_cmp expected actual &&
159 test_cmp expected.log actual.log &&
160 test_cmp expected.log actual.log-config &&
161 test_cmp expected actual.nolog
164 test_expect_success 'setup: expected shortlog for two branches' '
166 Merge branches ${apos}left${apos} and ${apos}right${apos}
184 test_expect_success 'shortlog for two branches' '
185 git config merge.log true &&
186 test_might_fail git config --unset-all merge.summary &&
187 git checkout master &&
189 git fetch . left right &&
190 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
192 test_might_fail git config --unset-all merge.log &&
193 git config merge.summary true &&
194 git checkout master &&
196 git fetch . left right &&
197 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
199 git config merge.log yes &&
200 test_might_fail git config --unset-all merge.summary &&
201 git checkout master &&
203 git fetch . left right &&
204 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
206 test_might_fail git config --unset-all merge.log &&
207 git config merge.summary yes &&
208 git checkout master &&
210 git fetch . left right &&
211 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
213 test_cmp expected actual1 &&
214 test_cmp expected actual2 &&
215 test_cmp expected actual3 &&
216 test_cmp expected actual4
219 test_expect_success 'merge-msg -F' '
220 test_might_fail git config --unset-all merge.log &&
221 git config merge.summary yes &&
222 git checkout master &&
224 git fetch . left right &&
225 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
226 test_cmp expected actual
229 test_expect_success 'merge-msg -F in subdirectory' '
230 test_might_fail git config --unset-all merge.log &&
231 git config merge.summary yes &&
232 git checkout master &&
234 git fetch . left right &&
236 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
239 git fmt-merge-msg -F FETCH_HEAD >../actual
241 test_cmp expected actual
244 test_expect_success 'merge-msg with nothing to merge' '
245 test_might_fail git config --unset-all merge.log &&
246 git config merge.summary yes &&
252 git checkout -b unrelated &&
255 git fmt-merge-msg <.git/FETCH_HEAD >../actual
258 test_cmp empty actual
261 test_expect_success 'merge-msg tag' '
262 cat >expected <<-EOF &&
263 Merge tag ${apos}tag-r3${apos}
265 * tag ${apos}tag-r3${apos}:
271 test_might_fail git config --unset-all merge.log &&
272 git config merge.summary yes &&
274 git checkout master &&
276 git fetch . tag tag-r3 &&
278 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
279 test_cmp expected actual
282 test_expect_success 'merge-msg two tags' '
283 cat >expected <<-EOF &&
284 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
286 * tag ${apos}tag-r3${apos}:
291 * tag ${apos}tag-l5${apos}:
299 test_might_fail git config --unset-all merge.log &&
300 git config merge.summary yes &&
302 git checkout master &&
304 git fetch . tag tag-r3 tag tag-l5 &&
306 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
307 test_cmp expected actual
310 test_expect_success 'merge-msg tag and branch' '
311 cat >expected <<-EOF &&
312 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
314 * tag ${apos}tag-r3${apos}:
327 test_might_fail git config --unset-all merge.log &&
328 git config merge.summary yes &&
330 git checkout master &&
332 git fetch . tag tag-r3 left &&
334 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
335 test_cmp expected actual
338 test_expect_success 'merge-msg lots of commits' '
341 Merge branch ${apos}long${apos}
355 git checkout master &&
359 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
360 test_cmp expected actual