]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6200-fmt-merge-msg.sh
merge-base --independent to print reduced parent list in a merge
[thirdparty/git.git] / t / t6200-fmt-merge-msg.sh
CommitLineData
30a95f30
JH
1#!/bin/sh
2#
3# Copyright (c) 2006, Junio C Hamano
4#
5
6test_description='fmt-merge-msg test'
7
8. ./test-lib.sh
9
30a95f30
JH
10test_expect_success setup '
11 echo one >one &&
12 git add one &&
6183a6ad 13 test_tick &&
30a95f30
JH
14 git commit -m "Initial" &&
15
419fe5bc
SB
16 git clone . remote &&
17
30a95f30
JH
18 echo uno >one &&
19 echo dos >two &&
20 git add two &&
6183a6ad 21 test_tick &&
30a95f30
JH
22 git commit -a -m "Second" &&
23
24 git checkout -b left &&
25
6183a6ad
SB
26 echo "c1" >one &&
27 test_tick &&
30a95f30
JH
28 git commit -a -m "Common #1" &&
29
6183a6ad
SB
30 echo "c2" >one &&
31 test_tick &&
30a95f30
JH
32 git commit -a -m "Common #2" &&
33
34 git branch right &&
35
6183a6ad
SB
36 echo "l3" >two &&
37 test_tick &&
30a95f30
JH
38 git commit -a -m "Left #3" &&
39
6183a6ad
SB
40 echo "l4" >two &&
41 test_tick &&
30a95f30
JH
42 git commit -a -m "Left #4" &&
43
6183a6ad
SB
44 echo "l5" >two &&
45 test_tick &&
30a95f30 46 git commit -a -m "Left #5" &&
6183a6ad 47 git tag tag-l5 &&
30a95f30
JH
48
49 git checkout right &&
50
6183a6ad 51 echo "r3" >three &&
30a95f30 52 git add three &&
6183a6ad 53 test_tick &&
30a95f30 54 git commit -a -m "Right #3" &&
6183a6ad 55 git tag tag-r3 &&
30a95f30 56
6183a6ad
SB
57 echo "r4" >three &&
58 test_tick &&
30a95f30
JH
59 git commit -a -m "Right #4" &&
60
6183a6ad
SB
61 echo "r5" >three &&
62 test_tick &&
30a95f30
JH
63 git commit -a -m "Right #5" &&
64
6d6f6e68
SB
65 git checkout -b long &&
66 i=0 &&
67 while test $i -lt 30
68 do
69 test_commit $i one &&
70 i=$(($i+1))
71 done &&
72
d834c96a 73 git show-branch &&
30a95f30 74
d834c96a
JN
75 apos="'\''"
76'
30a95f30 77
d834c96a
JN
78test_expect_success 'message for merging local branch' '
79 echo "Merge branch ${apos}left${apos}" >expected &&
30a95f30
JH
80
81 git checkout master &&
82 git fetch . left &&
83
84 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 85 test_cmp expected actual
30a95f30
JH
86'
87
d834c96a
JN
88test_expect_success 'message for merging external branch' '
89 echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
30a95f30
JH
90
91 git checkout master &&
4114156a 92 git fetch "$(pwd)" left &&
30a95f30
JH
93
94 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 95 test_cmp expected actual
30a95f30
JH
96'
97
d834c96a
JN
98test_expect_success '[merge] summary/log configuration' '
99 cat >expected <<-EOF &&
100 Merge branch ${apos}left${apos}
30a95f30 101
d834c96a
JN
102 * left:
103 Left #5
104 Left #4
105 Left #3
106 Common #2
107 Common #1
108 EOF
30a95f30 109
6cd9cfef 110 git config merge.log true &&
d834c96a 111 test_might_fail git config --unset-all merge.summary &&
6cd9cfef
SG
112
113 git checkout master &&
6183a6ad 114 test_tick &&
6cd9cfef
SG
115 git fetch . left &&
116
d834c96a 117 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
6cd9cfef 118
d834c96a 119 test_might_fail git config --unset-all merge.log &&
e0d10e1c 120 git config merge.summary true &&
30a95f30
JH
121
122 git checkout master &&
6183a6ad 123 test_tick &&
30a95f30
JH
124 git fetch . left &&
125
d834c96a 126 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
30a95f30 127
d834c96a
JN
128 test_cmp expected actual1 &&
129 test_cmp expected actual2
130'
30a95f30 131
d834c96a
JN
132test_expect_success 'setup: expected shortlog for two branches' '
133 cat >expected <<-EOF
134 Merge branches ${apos}left${apos} and ${apos}right${apos}
135
136 * left:
137 Left #5
138 Left #4
139 Left #3
140 Common #2
141 Common #1
142
143 * right:
144 Right #5
145 Right #4
146 Right #3
147 Common #2
148 Common #1
149 EOF
150'
6cd9cfef 151
d834c96a 152test_expect_success 'shortlog for two branches' '
6cd9cfef 153 git config merge.log true &&
d834c96a 154 test_might_fail git config --unset-all merge.summary &&
6cd9cfef 155 git checkout master &&
6183a6ad 156 test_tick &&
6cd9cfef 157 git fetch . left right &&
d834c96a 158 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
6cd9cfef 159
d834c96a 160 test_might_fail git config --unset-all merge.log &&
e0d10e1c 161 git config merge.summary true &&
30a95f30 162 git checkout master &&
6183a6ad 163 test_tick &&
30a95f30 164 git fetch . left right &&
d834c96a 165 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
30a95f30 166
6cd9cfef 167 git config merge.log yes &&
d834c96a 168 test_might_fail git config --unset-all merge.summary &&
6cd9cfef 169 git checkout master &&
6183a6ad 170 test_tick &&
6cd9cfef 171 git fetch . left right &&
d834c96a 172 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
6cd9cfef 173
d834c96a 174 test_might_fail git config --unset-all merge.log &&
e0d10e1c 175 git config merge.summary yes &&
30a95f30 176 git checkout master &&
6183a6ad 177 test_tick &&
30a95f30 178 git fetch . left right &&
d834c96a 179 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
30a95f30 180
d834c96a
JN
181 test_cmp expected actual1 &&
182 test_cmp expected actual2 &&
183 test_cmp expected actual3 &&
184 test_cmp expected actual4
30a95f30
JH
185'
186
4c8d4c14 187test_expect_success 'merge-msg -F' '
d834c96a 188 test_might_fail git config --unset-all merge.log &&
4c8d4c14 189 git config merge.summary yes &&
4c8d4c14 190 git checkout master &&
6183a6ad 191 test_tick &&
4c8d4c14 192 git fetch . left right &&
4c8d4c14
SB
193 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
194 test_cmp expected actual
195'
196
197test_expect_success 'merge-msg -F in subdirectory' '
d834c96a 198 test_might_fail git config --unset-all merge.log &&
4c8d4c14 199 git config merge.summary yes &&
4c8d4c14 200 git checkout master &&
6183a6ad 201 test_tick &&
4c8d4c14
SB
202 git fetch . left right &&
203 mkdir sub &&
204 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
205 (
206 cd sub &&
207 git fmt-merge-msg -F FETCH_HEAD >../actual
208 ) &&
209 test_cmp expected actual
210'
211
419fe5bc 212test_expect_success 'merge-msg with nothing to merge' '
d834c96a 213 test_might_fail git config --unset-all merge.log &&
419fe5bc
SB
214 git config merge.summary yes &&
215
d834c96a
JN
216 >empty &&
217
419fe5bc
SB
218 (
219 cd remote &&
220 git checkout -b unrelated &&
6183a6ad 221 test_tick &&
419fe5bc
SB
222 git fetch origin &&
223 git fmt-merge-msg <.git/FETCH_HEAD >../actual
224 ) &&
225
d834c96a 226 test_cmp empty actual
419fe5bc
SB
227'
228
6d6f6e68 229test_expect_success 'merge-msg tag' '
d834c96a
JN
230 cat >expected <<-EOF &&
231 Merge tag ${apos}tag-r3${apos}
232
233 * tag ${apos}tag-r3${apos}:
234 Right #3
235 Common #2
236 Common #1
237 EOF
6d6f6e68 238
d834c96a 239 test_might_fail git config --unset-all merge.log &&
6d6f6e68
SB
240 git config merge.summary yes &&
241
242 git checkout master &&
243 test_tick &&
244 git fetch . tag tag-r3 &&
245
246 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
247 test_cmp expected actual
248'
249
6d6f6e68 250test_expect_success 'merge-msg two tags' '
d834c96a
JN
251 cat >expected <<-EOF &&
252 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
253
254 * tag ${apos}tag-r3${apos}:
255 Right #3
256 Common #2
257 Common #1
258
259 * tag ${apos}tag-l5${apos}:
260 Left #5
261 Left #4
262 Left #3
263 Common #2
264 Common #1
265 EOF
266
267 test_might_fail git config --unset-all merge.log &&
6d6f6e68
SB
268 git config merge.summary yes &&
269
270 git checkout master &&
271 test_tick &&
272 git fetch . tag tag-r3 tag tag-l5 &&
273
274 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
275 test_cmp expected actual
276'
277
6d6f6e68 278test_expect_success 'merge-msg tag and branch' '
d834c96a
JN
279 cat >expected <<-EOF &&
280 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
281
282 * tag ${apos}tag-r3${apos}:
283 Right #3
284 Common #2
285 Common #1
286
287 * left:
288 Left #5
289 Left #4
290 Left #3
291 Common #2
292 Common #1
293 EOF
294
295 test_might_fail git config --unset-all merge.log &&
6d6f6e68
SB
296 git config merge.summary yes &&
297
298 git checkout master &&
299 test_tick &&
300 git fetch . tag tag-r3 left &&
301
302 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
303 test_cmp expected actual
304'
305
6d6f6e68 306test_expect_success 'merge-msg lots of commits' '
d834c96a
JN
307 {
308 cat <<-EOF &&
309 Merge branch ${apos}long${apos}
310
311 * long: (35 commits)
312 EOF
313
314 i=29 &&
315 while test $i -gt 9
316 do
317 echo " $i" &&
318 i=$(($i-1))
319 done &&
320 echo " ..."
321 } >expected &&
6d6f6e68
SB
322
323 git checkout master &&
324 test_tick &&
325 git fetch . long &&
326
6d6f6e68
SB
327 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
328 test_cmp expected actual
329'
330
30a95f30 331test_done