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
'setup: clear [merge] configuration' '
133 test_might_fail git config --unset-all merge.log &&
134 test_might_fail git config --unset-all merge.summary
137 test_expect_success
'setup FETCH_HEAD' '
138 git checkout master &&
143 test_expect_success
'merge.log=3 limits shortlog length' '
144 cat >expected <<-EOF &&
145 Merge branch ${apos}left${apos}
154 git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual &&
155 test_cmp expected actual
158 test_expect_success
'merge.log=5 shows all 5 commits' '
159 cat >expected <<-EOF &&
160 Merge branch ${apos}left${apos}
170 git -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual &&
171 test_cmp expected actual
174 test_expect_success
'merge.log=0 disables shortlog' '
175 echo "Merge branch ${apos}left${apos}" >expected
176 git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
177 test_cmp expected actual
180 test_expect_success
'fmt-merge-msg -m' '
181 echo "Sync with left" >expected &&
182 cat >expected.log <<-EOF &&
185 * ${apos}left${apos} of $(pwd):
193 test_might_fail git config --unset merge.log &&
194 test_might_fail git config --unset merge.summary &&
195 git checkout master &&
196 git fetch "$(pwd)" left &&
197 git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
198 git fmt-merge-msg --log -m "Sync with left" \
199 <.git/FETCH_HEAD >actual.log &&
200 git config merge.log true &&
201 git fmt-merge-msg -m "Sync with left" \
202 <.git/FETCH_HEAD >actual.log-config &&
203 git fmt-merge-msg --no-log -m "Sync with left" \
204 <.git/FETCH_HEAD >actual.nolog &&
206 test_cmp expected actual &&
207 test_cmp expected.log actual.log &&
208 test_cmp expected.log actual.log-config &&
209 test_cmp expected actual.nolog
212 test_expect_success
'setup: expected shortlog for two branches' '
214 Merge branches ${apos}left${apos} and ${apos}right${apos}
232 test_expect_success
'shortlog for two branches' '
233 git config merge.log true &&
234 test_might_fail git config --unset-all merge.summary &&
235 git checkout master &&
237 git fetch . left right &&
238 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
240 test_might_fail git config --unset-all merge.log &&
241 git config merge.summary true &&
242 git checkout master &&
244 git fetch . left right &&
245 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
247 git config merge.log yes &&
248 test_might_fail git config --unset-all merge.summary &&
249 git checkout master &&
251 git fetch . left right &&
252 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
254 test_might_fail git config --unset-all merge.log &&
255 git config merge.summary yes &&
256 git checkout master &&
258 git fetch . left right &&
259 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
261 test_cmp expected actual1 &&
262 test_cmp expected actual2 &&
263 test_cmp expected actual3 &&
264 test_cmp expected actual4
267 test_expect_success
'merge-msg -F' '
268 test_might_fail git config --unset-all merge.log &&
269 git config merge.summary yes &&
270 git checkout master &&
272 git fetch . left right &&
273 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
274 test_cmp expected actual
277 test_expect_success
'merge-msg -F in subdirectory' '
278 test_might_fail git config --unset-all merge.log &&
279 git config merge.summary yes &&
280 git checkout master &&
282 git fetch . left right &&
284 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
287 git fmt-merge-msg -F FETCH_HEAD >../actual
289 test_cmp expected actual
292 test_expect_success
'merge-msg with nothing to merge' '
293 test_might_fail git config --unset-all merge.log &&
294 git config merge.summary yes &&
300 git checkout -b unrelated &&
303 git fmt-merge-msg <.git/FETCH_HEAD >../actual
306 test_cmp empty actual
309 test_expect_success
'merge-msg tag' '
310 cat >expected <<-EOF &&
311 Merge tag ${apos}tag-r3${apos}
313 * tag ${apos}tag-r3${apos}:
319 test_might_fail git config --unset-all merge.log &&
320 git config merge.summary yes &&
322 git checkout master &&
324 git fetch . tag tag-r3 &&
326 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
327 test_cmp expected actual
330 test_expect_success
'merge-msg two tags' '
331 cat >expected <<-EOF &&
332 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
334 * tag ${apos}tag-r3${apos}:
339 * tag ${apos}tag-l5${apos}:
347 test_might_fail git config --unset-all merge.log &&
348 git config merge.summary yes &&
350 git checkout master &&
352 git fetch . tag tag-r3 tag tag-l5 &&
354 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
355 test_cmp expected actual
358 test_expect_success
'merge-msg tag and branch' '
359 cat >expected <<-EOF &&
360 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
362 * tag ${apos}tag-r3${apos}:
375 test_might_fail git config --unset-all merge.log &&
376 git config merge.summary yes &&
378 git checkout master &&
380 git fetch . tag tag-r3 left &&
382 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
383 test_cmp expected actual
386 test_expect_success
'merge-msg lots of commits' '
389 Merge branch ${apos}long${apos}
403 git checkout master &&
407 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
408 test_cmp expected actual