Git development
 help / color / mirror / Atom feed
* git-diff-tree(1) can already do the important parts of git-format-rev(1)
@ 2026-10-15 10:35 Kristoffer Haugsbakk
  2026-10-15 18:42 ` Kristoffer Haugsbakk
  0 siblings, 1 reply; 3+ messages in thread
From: Kristoffer Haugsbakk @ 2026-10-15 10:35 UTC (permalink / raw)
  To: git

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/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-17 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15 10:35 git-diff-tree(1) can already do the important parts of git-format-rev(1) Kristoffer Haugsbakk
2026-10-15 18:42 ` Kristoffer Haugsbakk
2026-10-17 16:34   ` Kristoffer Haugsbakk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox