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

[PATCH] Add tests for git log --pretty, --format and --oneline.

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Feb 24, 2009, 21:06 UTC
Message-ID
<1235509597-18336-1-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<7vljrvhh13.fsf@gitster.siamese.dyndns.org>
More specifically; --pretty=format, tformat and new %foo shortcut.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/t4202-log.sh |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 7b976ee..f1287fe 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -37,6 +37,46 @@ test_expect_success setup '
 
 '
 
+echo -ne "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
+test_expect_success 'pretty' '
+
+	git log --pretty="format:%s" > actual &&
+	test_cmp expect actual
+'
+
+echo -ne "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
+test_expect_success 'pretty (tformat)' '
+
+	git log --pretty="tformat:%s" > actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'pretty (shortcut)' '
+
+	git log --pretty="%s" > actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'format' '
+
+	git log --format="%s" > actual &&
+	test_cmp expect actual
+'
+
+cat > expect << EOF
+804a787 sixth
+394ef78 fifth
+5d31159 fourth
+2fbe8c0 third
+f7dab8e second
+3a2fdcb initial
+EOF
+test_expect_success 'oneline' '
+
+	git log --oneline > actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'diff-filter=A' '
 
 	actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) &&
-- 
1.6.1.3
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 17 in “--format, --pretty and --oneline”
  1. 0/3 --format, --pretty and --onelineNanako Shiraishi, Feb 24, 2009
  2. 1/3 Add --format that is a synonym to --prettyNanako Shiraishi, Feb 24, 2009
  3. 2/3 Give short-hands to --pretty=tformat:%formatstringNanako Shiraishi, Feb 24, 2009
  4. 3/3 Add --oneline that is a synonym to "--pretty=oneline --abbrev-commit"Nanako Shiraishi, Feb 24, 2009
  5. Junio C HamanoFeb 24, 2009
  6. Add tests for git log --pretty, --format and --oneline.Felipe Contreras, Feb 24, 2009
  7. Junio C HamanoFeb 25, 2009
  8. Jeff KingFeb 25, 2009
  9. Junio C HamanoFeb 25, 2009
  10. Jeff KingFeb 25, 2009
  11. bash completion: add --format= and --oneline options for "git log"Teemu Likonen, Feb 24, 2009
  12. bash completion: add --format= and --oneline options for "git log"Teemu Likonen, Feb 24, 2009
  13. Shawn O. PearceFeb 24, 2009
  14. Teemu LikonenFeb 24, 2009
  15. Shawn O. PearceFeb 24, 2009
  16. Teemu LikonenFeb 24, 2009
  17. Teemu LikonenFeb 27, 2009

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.