From: Junio C Hamano <gitster@pobox.com>
To: Drew Noakes <drew@drewnoakes.com>
Cc: git@vger.kernel.org
Subject: Re: Multiple consecutive null bytes with log -z --name-only
Date: Fri, 27 Jul 2018 15:12:30 -0700 [thread overview]
Message-ID: <xmqq36w4l44x.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <CAJd66x7ZHn=6AHFRXo5E4MhzEiW98Mpf37JRWv_18U5eYFeVJg@mail.gmail.com> (Drew Noakes's message of "Fri, 27 Jul 2018 21:20:54 +0100")
Drew Noakes <drew@drewnoakes.com> writes:
> Passing -z with --name-only causes double nulls.
>
> $ git log -z --pretty=format:"%H" --name-only | grep -obUaP "\x00\x00" | wc
> -l
> 8994
> $ git log -z --pretty=format:"%H" | grep -obUaP "\x00\x00" | wc -l
> 0
With --pretty that tells you to show %H and --name-only that tells
you to show names of paths that were touched by each commit, you'd
need to be able to distinguish commit object name (or whategver you
give --pretty=format to) and each pathname, and because you are
driving "log", you also should be able to see where info for one
commit ends and the next one starts.
So I'd imagine that for a commit that touches N paths, you would get
(one pathname followed by NUL) N times, and then another NUL after
that to let you know that you read all the pathnames for that
commit.
By the way, tools should be reading from "--format=...", not from
"--pretty=format:...". The --format=... option is for human
consumption and gives LF (or NUL when -z is used) the "separator"
semantics, i.e. when listing things A B and C, we would throw
separator in between but not before the first one (obviously) and
not after the last one. "--format=..." which is a synonym for
"--pretty=tformat:..." is designed for tool consumption and gives LF
(or NULL when -z i used) the "terminator" semantics, i.e. each item
in the output is followed by terminator, so in addition to LF/NUL
after A and B in the example in this paragraph, you also get one
after C, which is the last item.
prev parent reply other threads:[~2018-07-27 22:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-27 20:20 Multiple consecutive null bytes with log -z --name-only Drew Noakes
2018-07-27 22: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=xmqq36w4l44x.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=drew@drewnoakes.com \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).