From: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>
To: git@vger.kernel.org
Subject: git-diff-tree(1) can already do the important parts of git-format-rev(1)
Date: Thu, 15 Oct 2026 12:35:36 +0200 [thread overview]
Message-ID: <ce69d94e-7329-449d-b3c3-47d4f3aa608c@app.fastmail.com> (raw)
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”
And it’s even *better*. Because it supports `--notes` like git-log(1)
does. And probably everything else that the rev-list machinery
supports. git-format-rev(1) does not. The `--notes` display is not part
of pretty formatting itself.
(There are also some minor extra things you get from the pretty formats
(the built-in ones) used with git-log(1) and co. that you don’t get with
git-format-rev(1). Because git-format-rev(1) just uses `pretty.h` while
I think git-log(1) and co. use `log-tree.h`.)
But you do have the issue that you have to pass object names. With
git-format-rev(1) you can pass revision expressions. But you can just
stick a revs-to-OID pipe in front of it:
... | git cat-file --batch-command='%(objectname)' | ...
And then that’s taken care of.[2]
That’s for `git format-rev --stdin-mode=revs`. But there is a
concillation price in that `git format-rev --stdin-mode=text` can format
object names (full hex) in running text (by just tweaking the function
that `git name-rev --annotate-stdin` calls). But that was a nice bonus
and not why the command was made.
† 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/
next reply other threads:[~2026-10-15 10:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 10:35 Kristoffer Haugsbakk [this message]
2026-10-15 18:42 ` git-diff-tree(1) can already do the important parts of git-format-rev(1) Kristoffer Haugsbakk
2026-10-17 16:34 ` Kristoffer Haugsbakk
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=ce69d94e-7329-449d-b3c3-47d4f3aa608c@app.fastmail.com \
--to=kristofferhaugsbakk@fastmail.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