Subject: Re: [PATCH 0/4] rev-list: introduce NUL-delimited output mode

From: Junio C Hamano <[email-masked]>
Date: Fri, 14 Mar 2025 10:02:11 -0700

Jeff King <[email-masked]> writes:

> On Thu, Mar 13, 2025 at 11:41:56AM -0500, Justin Tobler wrote:
>
>> > Though that does mean that these two commands
>> > will behave differently:
>> > 
>> >   git log --stdin -z
>> >   git rev-list --stdin -z
>> > 
>> > which seems...not great. My earlier suggestion to tie "-z" to stdin
>> > handling was for consistency with other tools like grep. But if we
>> > already have cases where "-z" is only for output, maybe it is better to
>> > stay consistent with other parts of git. I.e., I was worried about us
>> > painting ourselves into a corner with your patches, but we may have
>> > already done so years ago. ;)
>> 
>> I think to some extent Git is already inconsistent here. IMO it would be
>> preferable for both input and output to use NUL as the delimiter when
>> machine parsing in git-rev-list(1) as that is the behavior I would
>> personally expect. I also agree with Patrick's reasoning else where in
>> this thread[1].
>> 
>> I'm open to discuss further though :)
>
> Nope, I don't have anything further to add. I just wanted to make sure
> my suggestion in the earlier part of the thread was not leading us
> accidentally down a bad path. ;) If the inconsistencies have been
> considered and we're OK with them, that sounds good to me (and the
> option handling in your v2 does seem to faithfully implement that).
>
> Thanks for all your responses.

The developers who know that the revision walk infrastructure is
shared between rev-list and log may wish that "-z" to mean the same
thing for these two commands, but the end-users do not have to, no?

After all, "git log" accepts "-z" but "git rev-list" does not in the
current system and nobody complained about the discrepancy so far.

Having said that, at the plumbing level, my preference is to have
two independent options "--nul-delimited-{output,input}".  It does
not prevent us from starting with a single "-z" that works as a
short-hand that flips both on (and is inconsistent with "git log" at
the Porcelain level), but we can make "-z" only for output for
consistency.  As long as we agree on the design to allow us to
control both sides independently, starting with "-z" that is only
for output may be the best way forward.