add tests of commit --squash
t7500: test expected behavior of commit --squash t3415: test interaction of commit --squash with rebase --autosquash t3900: test commit --squash with i18n encodings Signed-off-by: Pat Notz <patnotz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pat Notz committed
Nov 2, 2010 at 13:59 UTC
7951bd3029a849411181935f84600ddbcd97cd0c
4 files changed
+57
t/t3415-rebase-autosquash.sh
+4
@@ -115,4 +115,8 @@ test_expect_success 'use commit --fixup' '
115
test_auto_commit_flags fixup 1
116
'
117
118
+test_expect_success 'use commit --squash' '
119
+ test_auto_commit_flags squash 2
120
+'
121
+
122
test_done
t/t3900-i18n-commit.sh
+2
@@ -160,4 +160,6 @@ test_commit_autosquash_flags () {
160
161
test_commit_autosquash_flags eucJP fixup
162
163
+test_commit_autosquash_flags ISO-2022-JP squash '-m "squash message"'
164
+
165
test_done
t/t7500-commit.sh
+47
@@ -238,10 +238,57 @@ test_expect_success 'commit --fixup provides correct one-line commit message' '
238
commit_msg_is "fixup! target message subject line"
239
'
240
241
+test_expect_success 'commit --squash works with -F' '
242
+ commit_for_rebase_autosquash_setup &&
243
+ echo "log message from file" >msgfile &&
244
+ git commit --squash HEAD~1 -F msgfile &&
245
+ commit_msg_is "squash! target message subject linelog message from file"
246
+'
247
+
248
+test_expect_success 'commit --squash works with -m' '
249
+ commit_for_rebase_autosquash_setup &&
250
+ git commit --squash HEAD~1 -m "foo bar\nbaz" &&
251
+ commit_msg_is "squash! target message subject linefoo bar\nbaz"
252
+'
253
+
254
+test_expect_success 'commit --squash works with -C' '
255
+ commit_for_rebase_autosquash_setup &&
256
+ git commit --squash HEAD~1 -C HEAD &&
257
+ commit_msg_is "squash! target message subject lineintermediate commit"
258
+'
259
+
260
+test_expect_success 'commit --squash works with -c' '
261
+ commit_for_rebase_autosquash_setup &&
262
+ test_set_editor "$TEST_DIRECTORY"/t7500/edit-content &&
263
+ git commit --squash HEAD~1 -c HEAD &&
264
+ commit_msg_is "squash! target message subject lineedited commit"
265
+'
266
+
267
+test_expect_success 'commit --squash works with -C for same commit' '
268
+ commit_for_rebase_autosquash_setup &&
269
+ git commit --squash HEAD -C HEAD &&
270
+ commit_msg_is "squash! intermediate commit"
271
+'
272
+
273
+test_expect_success 'commit --squash works with -c for same commit' '
274
+ commit_for_rebase_autosquash_setup &&
275
+ test_set_editor "$TEST_DIRECTORY"/t7500/edit-content &&
276
+ git commit --squash HEAD -c HEAD &&
277
+ commit_msg_is "squash! edited commit"
278
+'
279
+
280
+test_expect_success 'commit --squash works with editor' '
281
+ commit_for_rebase_autosquash_setup &&
282
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
283
+ git commit --squash HEAD~1 &&
284
+ commit_msg_is "squash! target message subject linecommit message"
285
+'
286
+
287
test_expect_success 'invalid message options when using --fixup' '
288
echo changes >>foo &&
289
echo "message" >log &&
290
git add foo &&
291
+ test_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&
292
test_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&
293
test_must_fail git commit --fixup HEAD~1 -c HEAD~2 &&
294
test_must_fail git commit --fixup HEAD~1 -m "cmdline message" &&
t/t7500/edit-content
new
+4
@@ -0,0 +1,4 @@
1
+#!/bin/sh
2
+sed -e "s/intermediate/edited/g" <"$1" >"$1-"
3
+mv "$1-" "$1"
4
+exit 0