On Wed, 2016-10-19 at 15:39 -0700, Junio C Hamano wrote:
> Jacob Keller <[email protected]> writes:
>
> > Hi,
> >
> > On Wed, Oct 19, 2016 at 2:04 PM, Dennis Kaarsemaker
> > <[email protected]> wrote:
> > > Commit 660e113 (graph: add support for --line-prefix on all graph-aware
> > > output) changed the way commits were shown. Unfortunately this dropped
> > > the NUL between commits in --header mode. Restore the NUL and add a test
> > > for this feature.
> > >
> >
> >
> > Oops! Thanks for the bug fix.
> >
> > > Signed-off-by: Dennis Kaarsemaker <[email protected]>
> > > ---
> > > builtin/rev-list.c | 4 ++++
> > > t/t6000-rev-list-misc.sh | 7 +++++++
> > > 2 files changed, 11 insertions(+)
> > >
> > > diff --git a/builtin/rev-list.c b/builtin/rev-list.c
> > > index 8479f6e..cfa6a7d 100644
> > > --- a/builtin/rev-list.c
> > > +++ b/builtin/rev-list.c
> > > @@ -157,6 +157,10 @@ static void show_commit(struct commit *commit, void
> > > *data)
> > > if (revs->commit_format == CMIT_FMT_ONELINE)
> > > putchar('\n');
> > > }
> > > + if (revs->commit_format == CMIT_FMT_RAW) {
> > > + putchar(info->hdr_termination);
> > > + }
> > > +
> >
> >
> > This seems right to me. My one concern is that we make sure we restore
> > it for every case (in case it needs to be there for other formats?)
> > I'm not entirely sure about whether other non-raw modes need this or
> > not?
>
>
> Right. The original didn't do anything special for CMIT_FMT_RAW,
> and 660e113 did not remove anything special for CMIT_FMT_RAW, so it
> isn't immediately obvious why this patch is sufficient.
>
> Dennis, care to elaborate?
The original logic was (best seen with git show -w 660e113):
if(showing graphs) {
do pretty things
}
else {
just print the buffer and the header terminator
}
660e113 changed that to
do pretty things
Given that the 'do pretty things part' works for other uses of git rev-
list, it made sense that the \0 should only be added back in
CMIT_FMT_RAW mode. Changing the first putchar('\n') as Jacob proposes
(that mail arrived while I'm typing this) might work too, I haven't
tested it.
D.