Subject: Re: [PATCH v3 01/10] xdiff: delete static forward declarations in xprepare

From: Jeff King <[email-masked]>
Date: Sat, 20 Sep 2025 19:15:08 -0400

On Sat, Sep 20, 2025 at 03:52:41PM -0700, Junio C Hamano wrote:

> > PS I sometimes find:
> >
> >      git log --format='%(trailers:only,keyonly)' |
> >      sort | uniq -c | sort -rn
> >
> >    amusing to look through for this sort of thing.
> 
> The top entries are as expecte (this is with --since=5.years)
> 
>   24336 Signed-off-by
>   17501 
>     740 Helped-by
>     703 Reviewed-by
>     495 Acked-by
>     485 Reported-by
>     420 Mentored-by
>     186 Co-authored-by
>     164 Suggested-by
> 
> but I have to wonder what the empty one is.

I think %(trailers) always ends each trailer line with its own newline,
including the final one.  So then --format adds its own final newline,
and you get a bunch of blank lines between commits. It's easier to see
with --format='%h %s%n(trailers:only,keyonly)'.

I don't think you'd want to change %(trailers) to omit the final
newline, otherwise a format like:

  git log --format='%h %s%n%(trailers)---'

would break.

Possibly the formatter could be more clever about adding the final
newline only when the formatted text does not itself end with one. But I
suspect some people's custom formats do rely on the current behavior, so
you probably need some kind of new option or format placeholder.

-Peff