Re: [PATCH] pretty: add diff-stat log placeholders
- From
- Andrey Zarubin <zarandr@gmail.com>
- Date
- May 4, 2026, 21:00 UTC
- Message-ID
- <CAHGMpHAeSQ7xfm5AcfPNAEkuFwhfbwbU9dNgX1vk5qhC++1eFA@mail.gmail.com>
- In-Reply-To
- <xmqqmryfpxpg.fsf@gitster.g>
On Mon, May 4, 2026 at 8:09 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 33 quoted lines
> > "Andrey Zarubin via GitGitGadget" <gitgitgadget@gmail.com> writes: > > > From: Andrey Zarubin <zarandr@gmail.com> > > > > Currently, users who want per-commit line/file change counts in > > a custom log format must post-process `git log --shortstat` > > output because the pretty formatter exposes no equivalent > > placeholders. > > > > Introduce `%(diff-stat:files)`, `%(diff-stat:insertions)`, > > `%(diff-stat:deletions)`, and `%(diff-stat:lines)`, computed > > from the same diffstat machinery as `--shortstat` and cached > > once per commit during format expansion. > > > > Short aliases are provided as `%aF`, `%aA`, and `%aR`. The > > requested `%aI` and `%aD` forms are unavailable because those > > names already expand to author dates, so use additions/removals > > mnemonics instead. > > > > When log output is already walking a diff, the formatter reuses > > the current diff queue. Otherwise it computes a private summary > > lazily, so formats without these placeholders still pay no diff > > cost. > > > > Signed-off-by: Andrey Zarubin <zarandr@gmail.com> > > --- > > pretty: add diff-stat log placeholders > > Personally I find this a bit on the other side of the line between > sensible and insanity. Will we next be adding a new placeholder to > show the summary (i.e. list of created, deleted, and renamed paths) > and another placeholder to show the entire patch text?
I see the concern, and I agree that placeholders for `--summary` or full patch text would cross that line.
The distinction I had in mind is that these are bounded scalar values, not diff output. They are the same three counters already produced by `--shortstat`, and the main use case is one-line structured log output where today callers have to run `git log --shortstat` and parse/correlate the human-oriented output after the fact.
Path summaries and patch text are qualitatively different: they are multi-line, formatting-heavy, affected by quoting/color/output choices, and would effectively embed diff output inside the pretty formatter. I would not want this change to imply support for that direction.
If the short aliases make this feel too much like expanding the kitchen sink, I can drop them and keep only the explicit `%(diff-stat:<field>)` forms. I think the long forms make the intended scope clearer: numeric shortstat counters only.