Re: [PATCH v2] ls-tree: do not quote %(path) with -z
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 19, 2026, 16:12 UTC
- Message-ID
- <xmqq4idc2422.fsf@gitster.g>
- In-Reply-To
- <20261119-ls-tree-format-z-verbatim-path-v2-1-c014e4e4c96f@noam.me>
Noam Cohen via B4 Relay <devnull+noam.noam.me@kernel.org> writes:
Show 25 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. > ... > - quote_c_style(name, &sb, NULL, 0); > + if (options->null_termination) > + strbuf_addstr(&sb, name); > + else > + quote_c_style(name, &sb, NULL, 0); > strbuf_setlen(base, baselen); > ... > +test_expect_success 'ls-tree --format with -z does not quote paths' ' > + blob=$(git rev-parse HEAD:top-file.t) && > + tree=$(printf "100644 blob $blob\tdouble\"quote\n" | git mktree) && > + printf "blob double\"quote\0" >expect && > + git -c core.quotePath=true ls-tree -z \ > + --format="%(objecttype) %(path)" $tree >actual && > + test_cmp expect actual > +'
Everything looks as expected. Nicely done. Will queue. Thanks.