git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv5 8/8] add tests of commit --squash

From
Pat Notz <patnotz@gmail.com>
Date
Oct 7, 2010, 19:10 UTC
Message-ID
<1286478657-61581-9-git-send-email-patnotz@gmail.com>
In-Reply-To
<1286478657-61581-1-git-send-email-patnotz@gmail.com>

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>
---
As noted in the cover letter, one issue which limits the testing is
that rebase --autosquash does not (yet) consider encodings when
comparing commit subjects.  So, we can't test the case of a fixup! or
squash! commit having a different encoding than the commit with which
it will be combined.
 t/t3415-rebase-autosquash.sh |    4 +++
 t/t3900-i18n-commit.sh       |    2 +
 t/t7500-commit.sh            |   47 ++++++++++++++++++++++++++++++++++++++++++
 t/t7500/edit-content         |    4 +++
 4 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100755 t/t7500/edit-content
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index b77a413..0028533 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -115,4 +115,8 @@ test_expect_success 'use commit --fixup' '
 	test_auto_commit_flags fixup 1
 '
 
+test_expect_success 'use commit --squash' '
+	test_auto_commit_flags squash 2
+'
+
 test_done
diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh
index ff6d8dd..dfabb3a 100755
--- a/t/t3900-i18n-commit.sh
+++ b/t/t3900-i18n-commit.sh
@@ -159,4 +159,6 @@ test_commit_autosquash_flags () {
 
 test_commit_autosquash_flags eucJP fixup
 
+test_commit_autosquash_flags ISO-2022-JP squash '-m "squash message"'
+
 test_done
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index a41b819..162527c 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -238,10 +238,57 @@ test_expect_success 'commit --fixup provides correct one-line commit message' '
 	commit_msg_is "fixup! target message subject line"
 '
 
+test_expect_success 'commit --squash works with -F' '
+	commit_for_rebase_autosquash_setup &&
+	echo "log message from file" >msgfile &&
+	git commit --squash HEAD~1 -F msgfile  &&
+	commit_msg_is "squash! target message subject linelog message from file"
+'
+
+test_expect_success 'commit --squash works with -m' '
+	commit_for_rebase_autosquash_setup &&
+	git commit --squash HEAD~1 -m "foo bar\nbaz" &&
+	commit_msg_is "squash! target message subject linefoo bar\nbaz"
+'
+
+test_expect_success 'commit --squash works with -C' '
+	commit_for_rebase_autosquash_setup &&
+	git commit --squash HEAD~1 -C HEAD &&
+	commit_msg_is "squash! target message subject lineintermediate commit"
+'
+
+test_expect_success 'commit --squash works with -c' '
+	commit_for_rebase_autosquash_setup &&
+	test_set_editor "$TEST_DIRECTORY"/t7500/edit-content &&
+	git commit --squash HEAD~1 -c HEAD &&
+	commit_msg_is "squash! target message subject lineedited commit"
+'
+
+test_expect_success 'commit --squash works with -C for same commit' '
+	commit_for_rebase_autosquash_setup &&
+	git commit --squash HEAD -C HEAD &&
+	commit_msg_is "squash! intermediate commit"
+'
+
+test_expect_success 'commit --squash works with -c for same commit' '
+	commit_for_rebase_autosquash_setup &&
+	test_set_editor "$TEST_DIRECTORY"/t7500/edit-content &&
+	git commit --squash HEAD -c HEAD &&
+	commit_msg_is "squash! edited commit"
+'
+
+test_expect_success 'commit --squash works with editor' '
+	commit_for_rebase_autosquash_setup &&
+	test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
+	git commit --squash HEAD~1 &&
+	commit_msg_is "squash! target message subject linecommit message"
+'
+
 test_expect_success 'invalid message options when using --fixup' '
 	echo changes >>foo &&
 	echo "message" >log &&
 	git add foo &&
+	test_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&
 	test_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&
 	test_must_fail git commit --fixup HEAD~1 -c HEAD~2 &&
 	test_must_fail git commit --fixup HEAD~1 -m "cmdline message" &&
diff --git a/t/t7500/edit-content b/t/t7500/edit-content
new file mode 100755
index 0000000..08db9fd
--- /dev/null
+++ b/t/t7500/edit-content
@@ -0,0 +1,4 @@
+#!/bin/sh
+sed -e "s/intermediate/edited/g" <"$1" >"$1-"
+mv "$1-" "$1"
+exit 0
-- 
1.7.3.1
Previous: Pat NotzNext: Pat Notz
Message 15 of 17 in “[PATCHv5 0/8] Add commit message options for rebase --autosquash”
  1. Pat NotzOct 7, 2010
  2. 1/8 commit.c: prefer get_header() to manual searchingPat Notz, Oct 7, 2010
  3. Sverre RabbelierOct 7, 2010
  4. Sverre RabbelierOct 7, 2010
  5. Junio C HamanoOct 13, 2010
  6. 2/8 commit.c: new function for looking up a comit by namePat Notz, Oct 7, 2010
  7. Junio C HamanoOct 13, 2010
  8. 3/8 pretty.c: helper methods for getting output encodingsPat Notz, Oct 7, 2010
  9. 4/8 pretty.c: teach format_commit_message() to reencode the outputPat Notz, Oct 7, 2010
  10. Junio C HamanoOct 13, 2010
  11. Pat NotzOct 13, 2010
  12. 5/8 commit: --fixup option for use with rebase --autosquashPat Notz, Oct 7, 2010
  13. 6/8 add tests of commit --fixupPat Notz, Oct 7, 2010
  14. 7/8 commit: --squash option for use with rebase --autosquashPat Notz, Oct 7, 2010
  15. 8/8 add tests of commit --squashPat Notz, Oct 7, 2010
  16. Pat NotzOct 11, 2010
  17. Sverre RabbelierOct 12, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.