Re: [PATCH 0/4] rev-list: introduce NUL-delimited output mode
- From
Jeff King <peff@peff.net>
- Date
- Mar 11, 2025, 23:57 UTC
- Message-ID
- <20250311235720.GA73755@coredump.intra.peff.net>
- In-Reply-To
- <20250310192829.661692-1-jltobler@gmail.com>
On Mon, Mar 10, 2025 at 02:28:25PM -0500, Justin Tobler wrote:
Show 12 quoted lines
> To make machine parsing easier, this series introduces a NUL-delimited > output mode for git-rev-list(1) via a `-z` option following a suggestion > from Junio in a previous thread[1]. In this mode, instead of LF, each > object is delimited with two NUL bytes and any object metadata is > separated with a single NUL byte. Examples: > > <oid> NUL NUL > <oid> [NUL <path>] NUL NUL > ?<oid> [NUL <token>=<value>]... NUL NUL > > In this mode, path and value info are printed as-is without any special > encoding or truncation.
I think this is a good direction, but I have two compatibility questions:
1. What should "git rev-list -z --stdin" do? In most other programs
with a "-z" option it affects both input and output. I don't
particularly care about this case myself, but it will be hard to
change later. So we probably want to decide now. 2. I was a little surprised that rev-list already takes a "-z" option,
but it doesn't seem to do anything. I guess it's probably picked up
via diff_opt_parse(), though (I think) you can't actually trigger a
diff via rev-list itself. So even though this is a change in
behavior, probably nobody would have been using it until now? If it is possible to see some effect from "-z" now (I didn't dig
very far), then it may be better to continue to let the diff
options parser handle it, and simply pick the result out of
revs.diffopt.line_termination. As your patch 3 is written, I think
the diff code probably doesn't see it anymore at all.-Peff