git-commit: a bit more tests
Add tests for -s (sign-off) and multiple -m options Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Nov 10, 2007 at 01:49 UTC
5aa5cd460ccb6b18a1fcd53d566dadf049ceaf63
1 file changed
+69
t/t7501-commit.sh
+69
@@ -163,4 +163,73 @@ test_expect_success 'partial commit that involves removal (3)' '
163
164
'
165
166
+author="The Real Author <someguy@his.email.org>"
167
+test_expect_success 'amend commit to fix author' '
168
+
169
+ oldtick=$GIT_AUTHOR_DATE &&
170
+ test_tick &&
171
+ git reset --hard &&
172
+ git cat-file -p HEAD |
173
+ sed -e "s/author.*/author $author $oldtick/" \
174
+ -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \
175
+ expected &&
176
+ git commit --amend --author="$author" &&
177
+ git cat-file -p HEAD > current &&
178
+ diff expected current
179
+
180
+'
181
+
182
+test_expect_success 'sign off (1)' '
183
+
184
+ echo 1 >positive &&
185
+ git add positive &&
186
+ git commit -s -m "thank you" &&
187
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
188
+ (
189
+ echo thank you
190
+ echo
191
+ git var GIT_COMMITTER_IDENT |
192
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
193
+ ) >expected &&
194
+ diff -u expected actual
195
+
196
+'
197
+
198
+test_expect_success 'sign off (2)' '
199
+
200
+ echo 2 >positive &&
201
+ git add positive &&
202
+ existing="Signed-off-by: Watch This <watchthis@example.com>" &&
203
+ git commit -s -m "thank you
204
+
205
+$existing" &&
206
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
207
+ (
208
+ echo thank you
209
+ echo
210
+ echo $existing
211
+ git var GIT_COMMITTER_IDENT |
212
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
213
+ ) >expected &&
214
+ diff -u expected actual
215
+
216
+'
217
+
218
+test_expect_success 'multiple -m' '
219
+
220
+ >negative &&
221
+ git add negative &&
222
+ git commit -m "one" -m "two" -m "three" &&
223
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
224
+ (
225
+ echo one
226
+ echo
227
+ echo two
228
+ echo
229
+ echo three
230
+ ) >expected &&
231
+ diff -u expected actual
232
+
233
+'
234
+
235
test_done