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: expected shortlog for two branches' '
134 Merge branches ${apos}left${apos} and ${apos}right${apos}
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 &&
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 &&
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 &&
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 &&
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 &&
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 &&
202 git fetch . left right &&
204 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
207 git fmt-merge-msg -F FETCH_HEAD >../actual
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 &&
220 git checkout -b unrelated &&
223 git fmt-merge-msg <.git/FETCH_HEAD >../actual
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}:
239 test_might_fail git config --unset-all merge.log &&
240 git config merge.summary yes &&
242 git checkout master &&
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}:
259 * tag ${apos}tag-l5${apos}:
267 test_might_fail git config --unset-all merge.log &&
268 git config merge.summary yes &&
270 git checkout master &&
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}:
295 test_might_fail git config --unset-all merge.log &&
296 git config merge.summary yes &&
298 git checkout master &&
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' '
309 Merge branch ${apos}long${apos}
323 git checkout master &&
327 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
328 test_cmp expected actual