fmt-merge-msg: be quiet if nothing to merge
[alt-git.git] / t / t6200-fmt-merge-msg.sh
blobade209af438d25971497ef94bfd886e28b024c54
1 #!/bin/sh
3 # Copyright (c) 2006, Junio C Hamano
6 test_description='fmt-merge-msg test'
8 . ./test-lib.sh
10 datestamp=1151939923
11 setdate () {
12 GIT_COMMITTER_DATE="$datestamp +0200"
13 GIT_AUTHOR_DATE="$datestamp +0200"
14 datestamp=`expr "$datestamp" + 1`
15 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
18 test_expect_success setup '
19 echo one >one &&
20 git add one &&
21 setdate &&
22 git commit -m "Initial" &&
24 git clone . remote &&
26 echo uno >one &&
27 echo dos >two &&
28 git add two &&
29 setdate &&
30 git commit -a -m "Second" &&
32 git checkout -b left &&
34 echo $datestamp >one &&
35 setdate &&
36 git commit -a -m "Common #1" &&
38 echo $datestamp >one &&
39 setdate &&
40 git commit -a -m "Common #2" &&
42 git branch right &&
44 echo $datestamp >two &&
45 setdate &&
46 git commit -a -m "Left #3" &&
48 echo $datestamp >two &&
49 setdate &&
50 git commit -a -m "Left #4" &&
52 echo $datestamp >two &&
53 setdate &&
54 git commit -a -m "Left #5" &&
56 git checkout right &&
58 echo $datestamp >three &&
59 git add three &&
60 setdate &&
61 git commit -a -m "Right #3" &&
63 echo $datestamp >three &&
64 setdate &&
65 git commit -a -m "Right #4" &&
67 echo $datestamp >three &&
68 setdate &&
69 git commit -a -m "Right #5" &&
71 git show-branch
74 cat >expected <<\EOF
75 Merge branch 'left'
76 EOF
78 test_expect_success 'merge-msg test #1' '
80 git checkout master &&
81 git fetch . left &&
83 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
84 test_cmp expected actual
87 cat >expected <<EOF
88 Merge branch 'left' of $(pwd)
89 EOF
91 test_expect_success 'merge-msg test #2' '
93 git checkout master &&
94 git fetch "$(pwd)" left &&
96 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
97 test_cmp expected actual
100 cat >expected <<\EOF
101 Merge branch 'left'
103 * left:
104 Left #5
105 Left #4
106 Left #3
107 Common #2
108 Common #1
111 test_expect_success 'merge-msg test #3-1' '
113 git config --unset-all merge.log
114 git config --unset-all merge.summary
115 git config merge.log true &&
117 git checkout master &&
118 setdate &&
119 git fetch . left &&
121 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
122 test_cmp expected actual
125 test_expect_success 'merge-msg test #3-2' '
127 git config --unset-all merge.log
128 git config --unset-all merge.summary
129 git config merge.summary true &&
131 git checkout master &&
132 setdate &&
133 git fetch . left &&
135 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
136 test_cmp expected actual
139 cat >expected <<\EOF
140 Merge branches 'left' and 'right'
142 * left:
143 Left #5
144 Left #4
145 Left #3
146 Common #2
147 Common #1
149 * right:
150 Right #5
151 Right #4
152 Right #3
153 Common #2
154 Common #1
157 test_expect_success 'merge-msg test #4-1' '
159 git config --unset-all merge.log
160 git config --unset-all merge.summary
161 git config merge.log true &&
163 git checkout master &&
164 setdate &&
165 git fetch . left right &&
167 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
168 test_cmp expected actual
171 test_expect_success 'merge-msg test #4-2' '
173 git config --unset-all merge.log
174 git config --unset-all merge.summary
175 git config merge.summary true &&
177 git checkout master &&
178 setdate &&
179 git fetch . left right &&
181 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
182 test_cmp expected actual
185 test_expect_success 'merge-msg test #5-1' '
187 git config --unset-all merge.log
188 git config --unset-all merge.summary
189 git config merge.log yes &&
191 git checkout master &&
192 setdate &&
193 git fetch . left right &&
195 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
196 test_cmp expected actual
199 test_expect_success 'merge-msg test #5-2' '
201 git config --unset-all merge.log
202 git config --unset-all merge.summary
203 git config merge.summary yes &&
205 git checkout master &&
206 setdate &&
207 git fetch . left right &&
209 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
210 test_cmp expected actual
213 test_expect_success 'merge-msg -F' '
215 git config --unset-all merge.log
216 git config --unset-all merge.summary
217 git config merge.summary yes &&
219 git checkout master &&
220 setdate &&
221 git fetch . left right &&
223 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
224 test_cmp expected actual
227 test_expect_success 'merge-msg -F in subdirectory' '
229 git config --unset-all merge.log
230 git config --unset-all merge.summary
231 git config merge.summary yes &&
233 git checkout master &&
234 setdate &&
235 git fetch . left right &&
236 mkdir sub &&
237 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
239 cd sub &&
240 git fmt-merge-msg -F FETCH_HEAD >../actual
241 ) &&
242 test_cmp expected actual
245 test_expect_success 'merge-msg with nothing to merge' '
247 git config --unset-all merge.log
248 git config --unset-all merge.summary
249 git config merge.summary yes &&
252 cd remote &&
253 git checkout -b unrelated &&
254 setdate &&
255 git fetch origin &&
256 git fmt-merge-msg <.git/FETCH_HEAD >../actual
257 ) &&
259 test_cmp /dev/null actual
262 test_done