t6200 (fmt-merge-msg): style nitpicks
[alt-git.git] / t / t6200-fmt-merge-msg.sh
blob5553dff55a0a0319ec3d36b6259483077ecb1daa
1 #!/bin/sh
3 # Copyright (c) 2006, Junio C Hamano
6 test_description='fmt-merge-msg test'
8 . ./test-lib.sh
10 test_expect_success setup '
11 echo one >one &&
12 git add one &&
13 test_tick &&
14 git commit -m "Initial" &&
16 git clone . remote &&
18 echo uno >one &&
19 echo dos >two &&
20 git add two &&
21 test_tick &&
22 git commit -a -m "Second" &&
24 git checkout -b left &&
26 echo "c1" >one &&
27 test_tick &&
28 git commit -a -m "Common #1" &&
30 echo "c2" >one &&
31 test_tick &&
32 git commit -a -m "Common #2" &&
34 git branch right &&
36 echo "l3" >two &&
37 test_tick &&
38 git commit -a -m "Left #3" &&
40 echo "l4" >two &&
41 test_tick &&
42 git commit -a -m "Left #4" &&
44 echo "l5" >two &&
45 test_tick &&
46 git commit -a -m "Left #5" &&
47 git tag tag-l5 &&
49 git checkout right &&
51 echo "r3" >three &&
52 git add three &&
53 test_tick &&
54 git commit -a -m "Right #3" &&
55 git tag tag-r3 &&
57 echo "r4" >three &&
58 test_tick &&
59 git commit -a -m "Right #4" &&
61 echo "r5" >three &&
62 test_tick &&
63 git commit -a -m "Right #5" &&
65 git checkout -b long &&
66 i=0 &&
67 while test $i -lt 30
69 test_commit $i one &&
70 i=$(($i+1))
71 done &&
73 git show-branch &&
75 apos="'\''"
78 test_expect_success 'message for merging local branch' '
79 echo "Merge branch ${apos}left${apos}" >expected &&
81 git checkout master &&
82 git fetch . left &&
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}
102 * left:
103 Left #5
104 Left #4
105 Left #3
106 Common #2
107 Common #1
110 git config merge.log true &&
111 test_might_fail git config --unset-all merge.summary &&
113 git checkout master &&
114 test_tick &&
115 git fetch . left &&
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 &&
123 test_tick &&
124 git fetch . left &&
126 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
128 test_cmp expected actual1 &&
129 test_cmp expected actual2
132 test_expect_success 'setup: expected shortlog for two branches' '
133 cat >expected <<-EOF
134 Merge branches ${apos}left${apos} and ${apos}right${apos}
136 * left:
137 Left #5
138 Left #4
139 Left #3
140 Common #2
141 Common #1
143 * right:
144 Right #5
145 Right #4
146 Right #3
147 Common #2
148 Common #1
152 test_expect_success 'shortlog for two branches' '
153 git config merge.log true &&
154 test_might_fail git config --unset-all merge.summary &&
155 git checkout master &&
156 test_tick &&
157 git fetch . left right &&
158 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
160 test_might_fail git config --unset-all merge.log &&
161 git config merge.summary true &&
162 git checkout master &&
163 test_tick &&
164 git fetch . left right &&
165 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
167 git config merge.log yes &&
168 test_might_fail git config --unset-all merge.summary &&
169 git checkout master &&
170 test_tick &&
171 git fetch . left right &&
172 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
174 test_might_fail git config --unset-all merge.log &&
175 git config merge.summary yes &&
176 git checkout master &&
177 test_tick &&
178 git fetch . left right &&
179 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
181 test_cmp expected actual1 &&
182 test_cmp expected actual2 &&
183 test_cmp expected actual3 &&
184 test_cmp expected actual4
187 test_expect_success 'merge-msg -F' '
188 test_might_fail git config --unset-all merge.log &&
189 git config merge.summary yes &&
190 git checkout master &&
191 test_tick &&
192 git fetch . left right &&
193 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
194 test_cmp expected actual
197 test_expect_success 'merge-msg -F in subdirectory' '
198 test_might_fail git config --unset-all merge.log &&
199 git config merge.summary yes &&
200 git checkout master &&
201 test_tick &&
202 git fetch . left right &&
203 mkdir sub &&
204 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
206 cd sub &&
207 git fmt-merge-msg -F FETCH_HEAD >../actual
208 ) &&
209 test_cmp expected actual
212 test_expect_success 'merge-msg with nothing to merge' '
213 test_might_fail git config --unset-all merge.log &&
214 git config merge.summary yes &&
216 >empty &&
219 cd remote &&
220 git checkout -b unrelated &&
221 test_tick &&
222 git fetch origin &&
223 git fmt-merge-msg <.git/FETCH_HEAD >../actual
224 ) &&
226 test_cmp empty actual
229 test_expect_success 'merge-msg tag' '
230 cat >expected <<-EOF &&
231 Merge tag ${apos}tag-r3${apos}
233 * tag ${apos}tag-r3${apos}:
234 Right #3
235 Common #2
236 Common #1
239 test_might_fail git config --unset-all merge.log &&
240 git config merge.summary yes &&
242 git checkout master &&
243 test_tick &&
244 git fetch . tag tag-r3 &&
246 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
247 test_cmp expected actual
250 test_expect_success 'merge-msg two tags' '
251 cat >expected <<-EOF &&
252 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
254 * tag ${apos}tag-r3${apos}:
255 Right #3
256 Common #2
257 Common #1
259 * tag ${apos}tag-l5${apos}:
260 Left #5
261 Left #4
262 Left #3
263 Common #2
264 Common #1
267 test_might_fail git config --unset-all merge.log &&
268 git config merge.summary yes &&
270 git checkout master &&
271 test_tick &&
272 git fetch . tag tag-r3 tag tag-l5 &&
274 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
275 test_cmp expected actual
278 test_expect_success 'merge-msg tag and branch' '
279 cat >expected <<-EOF &&
280 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
282 * tag ${apos}tag-r3${apos}:
283 Right #3
284 Common #2
285 Common #1
287 * left:
288 Left #5
289 Left #4
290 Left #3
291 Common #2
292 Common #1
295 test_might_fail git config --unset-all merge.log &&
296 git config merge.summary yes &&
298 git checkout master &&
299 test_tick &&
300 git fetch . tag tag-r3 left &&
302 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
303 test_cmp expected actual
306 test_expect_success 'merge-msg lots of commits' '
308 cat <<-EOF &&
309 Merge branch ${apos}long${apos}
311 * long: (35 commits)
314 i=29 &&
315 while test $i -gt 9
317 echo " $i" &&
318 i=$(($i-1))
319 done &&
320 echo " ..."
321 } >expected &&
323 git checkout master &&
324 test_tick &&
325 git fetch . long &&
327 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
328 test_cmp expected actual
331 test_done