Re: git-diff-tree(1) can already do the important parts of git-format-rev(1)
- From
- Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
- Date
- Oct 15, 2026, 18:42 UTC
- Message-ID
- <2c1656e2-a054-43c2-94cc-31625f8c69e9@app.fastmail.com>
- In-Reply-To
- <ce69d94e-7329-449d-b3c3-47d4f3aa608c@app.fastmail.com>
On Thu, Oct 15, 2026, at 12:35, Kristoffer Haugsbakk wrote:
Show 19 quoted lines
> git-format-rev(1) is an experimental command from Git 2.55.0. It was > introduced because no command was found for the use case of pretty > formatting one revision at a time from standard in (stdin). See > [Discussion] on the doc. > > 🔗 Discussion: https://git-scm.com/docs/git-format-rev#_discussion > > But yesterday someone was reading through all of git-rev-list(1). And > this is one of the examples: > > git rev-list HEAD | > git diff-tree --stdin --format=medium -p > > And if one turns on merge display and off patch display. > > git rev-list HEAD | > git diff-tree --stdin --format=medium --no-patch -m > > You have “on-demand pretty formatting”
But for multiline pretties you need NUL termination. And this is what `-z` says:
When --raw, --numstat, --name-only or --name-status has been given,
do not munge pathnames and use NULs as output field terminators. Without this option, pathnames with "unusual" characters are quoted
as explained for the configuration variable core.quotePath (see
git-config(1)).So `-z` only applies to some primitive and name-centric diff formats. And that’s why my later footnote is wrong:
Show 8 quoted lines
>[snip] > > † 1: git-format-rev(1) also supports NUL-terminated input in order to > deal with multiline revision expressions.[3] And `-Z` for > git-cat-file(1) does that too (both input and output), so the pair > git-cat-file(1)/git-diff-tree(1) is equally expressive. > > 🔗 3: https://lore.kernel.org/git/e8bb57a2-8eff-4f72-96ca-72d8880901e0@gmail.com/