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

Re: [PATCH v2] log-tree: use custom line terminator in line termination mode

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 30, 2012, 22:58 UTC
Message-ID
<7vd36oesjr.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1335817705-24718-1-git-send-email-jk@jk.gs>
Jan Krüger <jk@jk.gs> writes:
Show 9 quoted lines
> When using a custom format in line termination mode (as opposed to line
> separation mode), the configured line terminator is not used, so things
> like "git log --pretty=tformat:%H -z" do not work properly.
>
> Make it use the line terminator the user ordered.
>
> Signed-off-by: Jan Krüger <jk@jk.gs>
> ---
>  Here are two simple tests, for both format: and tformat: with -z.
Thanks for being thorough. Very much appreciated.
Having said that, are we sure that
	printf "add bar\0initial"

works per specification, or merely works by accident in some implementation?

In C, we have to write this as printf("add bar%cinitial", 0), and the above makes my stomach feel a bit queasy.

Admittedly we have "printf "\0\0" in t6024 and we haven't seen anybody complain for the past 6 years, so perhaps I shouldn't be worried too much about this.

Show 21 quoted lines
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 2ae9faa..03a73ba 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -71,4 +71,16 @@ test_expect_success 'alias loop' '
>  	test_must_fail git log --pretty=test-foo
>  '
>  
> +printf "add bar\0initial" > expected
> +test_expect_success 'NUL separation' '
> +	git log -z --pretty="format:%s" >actual &&
> +	test_cmp expected actual
> +'
> +
> +printf "add bar\0initial\0" > expected
> +test_expect_success 'NUL termination' '
> +	git log -z --pretty="tformat:%s" >actual &&
> +	test_cmp expected actual
> +'
> +
>  test_done
Previous: Jan KrügerNext: Jan Krüger
Message 7 of 17 in “git log -z still outputting newlines?”
  1. Randal L. SchwartzApr 30, 2012
  2. Andreas SchwabApr 30, 2012
  3. Thomas RastApr 30, 2012
  4. log-tree: use custom line terminator in line termination modeJan Krüger, Apr 30, 2012
  5. Junio C HamanoApr 30, 2012
  6. log-tree: use custom line terminator in line termination modeJan Krüger, Apr 30, 2012
  7. Junio C HamanoApr 30, 2012
  8. Jan KrügerApr 30, 2012
  9. Andreas SchwabMay 1, 2012
  10. Junio C HamanoMay 1, 2012
  11. Andreas SchwabMay 1, 2012
  12. Randal L. SchwartzMay 1, 2012
  13. Junio C HamanoMay 1, 2012
  14. Jeff KingMay 1, 2012
  15. Junio C HamanoMay 1, 2012
  16. Junio C HamanoMay 1, 2012
  17. Junio C HamanoMay 1, 2012

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.