Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Noam Cohen via B4 Relay <devnull+noam.noam.me@kernel.org>
Cc: git@vger.kernel.org, "Teng Long" <dyroneteng@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"René Scharfe" <l.s.r@web.de>, "Noam Cohen" <noam@noam.me>
Subject: Re: [PATCH v2] ls-tree: do not quote %(path) with -z
Date: Thu, 19 Nov 2026 08:12:37 -0800	[thread overview]
Message-ID: <xmqq4idc2422.fsf@gitster.g> (raw)
In-Reply-To: <20261119-ls-tree-format-z-verbatim-path-v2-1-c014e4e4c96f@noam.me> (Noam Cohen via's message of "Thu, 19 Nov 2026 03:43:01 +0000")

Noam Cohen via B4 Relay <devnull+noam.noam.me@kernel.org> writes:

> 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.


      reply	other threads:[~2026-11-19 16:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 23:04 [PATCH] ls-tree: do not quote %(path) with -z Noam Cohen via B4 Relay
2026-11-18 23:20 ` Junio C Hamano
2026-11-18 23:45   ` Noam Cohen
2026-11-19  1:24     ` Junio C Hamano
2026-11-19  3:43 ` [PATCH v2] " Noam Cohen via B4 Relay
2026-11-19 16:12   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq4idc2422.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=devnull+noam.noam.me@kernel.org \
    --cc=dyroneteng@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --cc=noam@noam.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox