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

Re: [PATCH] ls-tree: do not quote %(path) with -z

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2026, 23:20 UTC
Message-ID
<xmqqcxs120c8.fsf@gitster.g>
In-Reply-To
<20261118-ls-tree-format-z-verbatim-path-v1-1-718987241861@noam.me>
Noam Cohen via B4 Relay <devnull+noam.noam.me@kernel.org> writes:
Show 9 quoted lines
> From: Noam Cohen <noam@noam.me>
>
> With -z, "git ls-tree" is documented to output the filename verbatim,
> but since 455923e0a1 (ls-tree: introduce "--format" option,
> 2022-03-23) the %(path) placeholder of a custom --format is always
> C-quoted.
>
> Output it verbatim when -z is given, like "git ls-files --format"
> already does.

ce74de931d (ls-files: introduce "--format" option, 2022-07-23) was the one that added --format, and the documentation added by the commit does talk about -z. But curiously, it does not add any test that exercises --format="%(path)" combined with -z.

The code change is trivially correct.
Show 5 quoted lines
>  test_expect_success 'setup' '
> -	setup_basic_ls_tree_data
> +	setup_basic_ls_tree_data &&
> +	test_commit נעם
>  '
Do we have to really use characters outside US-ASCII?
Show 7 quoted lines
> @@ -76,4 +77,10 @@ test_ls_tree_format \
>  	"--full-tree" \
>  	"--full-tree"
>  
> +test_expect_success 'ls-tree --format with -z does not quote paths' '
> +	printf "blob נעם.t\0" >expect &&
> +	git ls-tree -z --format="%(objecttype) %(path)" HEAD נעם.t >actual &&
OK, perhaps.
Previous: Noam Cohen via B4 RelayNext: Noam Cohen
Message 2 of 6 in “ls-tree: do not quote %(path) with -z”
  1. ls-tree: do not quote %(path) with -zNoam Cohen via B4 Relay, Nov 18, 2026
  2. Junio C HamanoNov 18, 2026
  3. Noam CohenNov 18, 2026
  4. Junio C HamanoNov 19, 2026
  5. ls-tree: do not quote %(path) with -zNoam Cohen via B4 Relay, Nov 19, 2026
  6. Junio C HamanoNov 19, 2026

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.