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

[PATCH 1/3] t7502-commit: add tests for summary output

From
Tay Ray Chuan <rctay89@gmail.com>
Date
May 24, 2010, 09:47 UTC
Message-ID
<1274694452-4200-2-git-send-email-rctay89@gmail.com>
In-Reply-To
<1274694452-4200-1-git-send-email-rctay89@gmail.com>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
 t/t7502-commit.sh |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 844fb43..589e8e6 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -4,8 +4,44 @@ test_description='git commit porcelain-ish'
 
 . ./test-lib.sh
 
+# Arguments: [<prefix] [<commit message>]
+check_summary_oneline() {
+	test_tick &&
+	git commit -m "$2" | head -1 > act &&
+
+	# branch name
+	SUMMARY_PREFIX="$(git name-rev --name-only HEAD)" &&
+
+	# append the "special" prefix, like "root-commit", "detached HEAD"
+	if test -n "$1"
+	then
+		SUMMARY_PREFIX="$SUMMARY_PREFIX ($1)"
+	fi
+
+	# abbrev SHA-1
+	SUMMARY_POSTFIX="$(git log -1 --pretty='format:%h')"
+	echo "[$SUMMARY_PREFIX $SUMMARY_POSTFIX] $2" >exp &&
+
+	test_cmp exp act
+}
+
+test_expect_success 'output summary format' '
+
+	echo new >file1 &&
+	git add file1 &&
+	check_summary_oneline "root-commit" "initial" &&
+
+	echo change >>file1 &&
+	git add file1 &&
+	check_summary_oneline "" "a change"
+'
+
 test_expect_success 'the basics' '
 
+	# this is needed for the "partial removal" test to pass
+	git rm file1 &&
+	git commit -m "cleanup" &&
+
 	echo doing partial >"commit is" &&
 	mkdir not &&
 	echo very much encouraged but we should >not/forbid &&
-- 
1.7.1.189.g07419
Previous: Tay Ray ChuanNext: Tay Ray Chuan
Message 2 of 17 in “commit: fix abbrev-sha regression”
  1. 0/3 commit: fix abbrev-sha regressionTay Ray Chuan, May 24, 2010
  2. 1/3 t7502-commit: add tests for summary outputTay Ray Chuan, May 24, 2010
  3. 2/3 t7502-commit: add summary output tests for empty and merge commitsTay Ray Chuan, May 24, 2010
  4. 3/3 commit: show abbreviated sha for commits with empty diffsTay Ray Chuan, May 24, 2010
  5. Junio C HamanoMay 26, 2010
  6. Tay Ray ChuanMay 26, 2010
  7. Tay Ray ChuanMay 26, 2010
  8. Junio C HamanoMay 26, 2010
  9. Tay Ray ChuanMay 26, 2010
  10. 0/3 commit: fix abbrev-sha regressionTay Ray Chuan, May 27, 2010
  11. 1/3 t7502-commit: add tests for summary outputTay Ray Chuan, May 27, 2010
  12. 2/3 t7502-commit: add summary output tests for empty and merge commitsTay Ray Chuan, May 27, 2010
  13. 3/3 commit::print_summary(): set rev_info.always_show_header to 1Tay Ray Chuan, May 27, 2010
  14. Junio C HamanoMay 29, 2010
  15. Tay Ray ChuanMay 29, 2010
  16. 3/3 commit::print_summary(): don't use format_commit_message()Tay Ray Chuan, Jun 12, 2010
  17. Will PalmerMay 27, 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.