Skip to content

Commit 7951bd3

Browse files
patnotzgitster
authored andcommitted
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>
1 parent 89ac122 commit 7951bd3

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

t/t3415-rebase-autosquash.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,8 @@ test_expect_success 'use commit --fixup' '
115115
test_auto_commit_flags fixup 1
116116
'
117117

118+
test_expect_success 'use commit --squash' '
119+
test_auto_commit_flags squash 2
120+
'
121+
118122
test_done

t/t3900-i18n-commit.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,6 @@ test_commit_autosquash_flags () {
160160

161161
test_commit_autosquash_flags eucJP fixup
162162

163+
test_commit_autosquash_flags ISO-2022-JP squash '-m "squash message"'
164+
163165
test_done

t/t7500-commit.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,57 @@ test_expect_success 'commit --fixup provides correct one-line commit message' '
238238
commit_msg_is "fixup! target message subject line"
239239
'
240240

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+
241287
test_expect_success 'invalid message options when using --fixup' '
242288
echo changes >>foo &&
243289
echo "message" >log &&
244290
git add foo &&
291+
test_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&
245292
test_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&
246293
test_must_fail git commit --fixup HEAD~1 -c HEAD~2 &&
247294
test_must_fail git commit --fixup HEAD~1 -m "cmdline message" &&

t/t7500/edit-content

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
sed -e "s/intermediate/edited/g" <"$1" >"$1-"
3+
mv "$1-" "$1"
4+
exit 0

0 commit comments

Comments
 (0)