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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 25, 2009, 09:54 UTC
Message-ID
<7vtz6i4zah.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1235509597-18336-1-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 6 quoted lines
> 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(-)

Because 4202 seems to be about testing the log functionality and they rely on correctly working format output to verify other aspects of the operation of "git log", I initially was not sure if this is the right place to add these new tests. After looking around I didn't find any existing test that checks the various --pretty output formats that the new tests can be added, so this probably is as good a place as any.

Show 16 quoted lines
> 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

We avoid "echo -e" to cater to people whose echo does not like it and instead use printf for things like this.

Other than that, the patch looked Ok.  I queued it with a minor fixup.
Thanks.
Previous: Felipe ContrerasNext: Jeff King
Message 7 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.