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_COMMITTER_NAME="Another Committer" \
39 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #3" &&
43 GIT_COMMITTER_NAME="Another Committer" \
44 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #4" &&
48 GIT_COMMITTER_NAME="Another Committer" \
49 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #5" &&
57 git commit -a -m "Right #3" &&
62 git commit -a -m "Right #4" &&
66 git commit -a -m "Right #5" &&
68 git checkout -b long &&
81 test_expect_success 'message for merging local branch' '
82 echo "Merge branch ${apos}left${apos}" >expected &&
84 git checkout master &&
87 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
88 test_cmp expected actual
91 test_expect_success 'message for merging external branch' '
92 echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
94 git checkout master &&
95 git fetch "$(pwd)" left &&
97 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
98 test_cmp expected actual
101 test_expect_success '[merge] summary/log configuration' '
102 cat >expected <<-EOF &&
103 Merge branch ${apos}left${apos}
105 # By Another Author (3) and A U Thor (2)
106 # Via Another Committer
115 git config merge.log true &&
116 test_might_fail git config --unset-all merge.summary &&
118 git checkout master &&
122 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
124 test_might_fail git config --unset-all merge.log &&
125 git config merge.summary true &&
127 git checkout master &&
131 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
133 test_cmp expected actual1 &&
134 test_cmp expected actual2
137 test_expect_success 'setup: clear [merge] configuration' '
138 test_might_fail git config --unset-all merge.log &&
139 test_might_fail git config --unset-all merge.summary
142 test_expect_success 'setup FETCH_HEAD' '
143 git checkout master &&
148 test_expect_success 'merge.log=3 limits shortlog length' '
149 cat >expected <<-EOF &&
150 Merge branch ${apos}left${apos}
152 # By Another Author (3) and A U Thor (2)
153 # Via Another Committer
161 git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual &&
162 test_cmp expected actual
165 test_expect_success 'merge.log=5 shows all 5 commits' '
166 cat >expected <<-EOF &&
167 Merge branch ${apos}left${apos}
169 # By Another Author (3) and A U Thor (2)
170 # Via Another Committer
179 git -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual &&
180 test_cmp expected actual
183 test_expect_success 'merge.log=0 disables shortlog' '
184 echo "Merge branch ${apos}left${apos}" >expected
185 git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
186 test_cmp expected actual
189 test_expect_success '--log=3 limits shortlog length' '
190 cat >expected <<-EOF &&
191 Merge branch ${apos}left${apos}
193 # By Another Author (3) and A U Thor (2)
194 # Via Another Committer
202 git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual &&
203 test_cmp expected actual
206 test_expect_success '--log=5 shows all 5 commits' '
207 cat >expected <<-EOF &&
208 Merge branch ${apos}left${apos}
210 # By Another Author (3) and A U Thor (2)
211 # Via Another Committer
220 git fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
221 test_cmp expected actual
224 test_expect_success '--no-log disables shortlog' '
225 echo "Merge branch ${apos}left${apos}" >expected &&
226 git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
227 test_cmp expected actual
230 test_expect_success '--log=0 disables shortlog' '
231 echo "Merge branch ${apos}left${apos}" >expected &&
232 git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
233 test_cmp expected actual
236 test_expect_success 'fmt-merge-msg -m' '
237 echo "Sync with left" >expected &&
238 cat >expected.log <<-EOF &&
241 # By Another Author (3) and A U Thor (2)
242 # Via Another Committer
243 * ${apos}left${apos} of $(pwd):
251 test_might_fail git config --unset merge.log &&
252 test_might_fail git config --unset merge.summary &&
253 git checkout master &&
254 git fetch "$(pwd)" left &&
255 git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
256 git fmt-merge-msg --log -m "Sync with left" \
257 <.git/FETCH_HEAD >actual.log &&
258 git config merge.log true &&
259 git fmt-merge-msg -m "Sync with left" \
260 <.git/FETCH_HEAD >actual.log-config &&
261 git fmt-merge-msg --no-log -m "Sync with left" \
262 <.git/FETCH_HEAD >actual.nolog &&
264 test_cmp expected actual &&
265 test_cmp expected.log actual.log &&
266 test_cmp expected.log actual.log-config &&
267 test_cmp expected actual.nolog
270 test_expect_success 'setup: expected shortlog for two branches' '
272 Merge branches ${apos}left${apos} and ${apos}right${apos}
274 # By Another Author (3) and A U Thor (2)
275 # Via Another Committer
292 test_expect_success 'shortlog for two branches' '
293 git config merge.log true &&
294 test_might_fail git config --unset-all merge.summary &&
295 git checkout master &&
297 git fetch . left right &&
298 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
300 test_might_fail git config --unset-all merge.log &&
301 git config merge.summary true &&
302 git checkout master &&
304 git fetch . left right &&
305 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
307 git config merge.log yes &&
308 test_might_fail git config --unset-all merge.summary &&
309 git checkout master &&
311 git fetch . left right &&
312 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
314 test_might_fail git config --unset-all merge.log &&
315 git config merge.summary yes &&
316 git checkout master &&
318 git fetch . left right &&
319 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
321 test_cmp expected actual1 &&
322 test_cmp expected actual2 &&
323 test_cmp expected actual3 &&
324 test_cmp expected actual4
327 test_expect_success 'merge-msg -F' '
328 test_might_fail git config --unset-all merge.log &&
329 git config merge.summary yes &&
330 git checkout master &&
332 git fetch . left right &&
333 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
334 test_cmp expected actual
337 test_expect_success 'merge-msg -F in subdirectory' '
338 test_might_fail git config --unset-all merge.log &&
339 git config merge.summary yes &&
340 git checkout master &&
342 git fetch . left right &&
344 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
347 git fmt-merge-msg -F FETCH_HEAD >../actual
349 test_cmp expected actual
352 test_expect_success 'merge-msg with nothing to merge' '
353 test_might_fail git config --unset-all merge.log &&
354 git config merge.summary yes &&
360 git checkout -b unrelated &&
363 git fmt-merge-msg <.git/FETCH_HEAD >../actual
366 test_cmp empty actual
369 test_expect_success 'merge-msg tag' '
370 cat >expected <<-EOF &&
371 Merge tag ${apos}tag-r3${apos}
373 * tag ${apos}tag-r3${apos}:
379 test_might_fail git config --unset-all merge.log &&
380 git config merge.summary yes &&
382 git checkout master &&
384 git fetch . tag tag-r3 &&
386 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
387 test_cmp expected actual
390 test_expect_success 'merge-msg two tags' '
391 cat >expected <<-EOF &&
392 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
394 * tag ${apos}tag-r3${apos}:
399 # By Another Author (3) and A U Thor (2)
400 # Via Another Committer
401 * tag ${apos}tag-l5${apos}:
409 test_might_fail git config --unset-all merge.log &&
410 git config merge.summary yes &&
412 git checkout master &&
414 git fetch . tag tag-r3 tag tag-l5 &&
416 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
417 test_cmp expected actual
420 test_expect_success 'merge-msg tag and branch' '
421 cat >expected <<-EOF &&
422 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
424 * tag ${apos}tag-r3${apos}:
429 # By Another Author (3) and A U Thor (2)
430 # Via Another Committer
439 test_might_fail git config --unset-all merge.log &&
440 git config merge.summary yes &&
442 git checkout master &&
444 git fetch . tag tag-r3 left &&
446 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
447 test_cmp expected actual
450 test_expect_success 'merge-msg lots of commits' '
453 Merge branch ${apos}long${apos}
467 git checkout master &&
471 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
472 test_cmp expected actual