git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-diff-tree(1) can already do the important parts of git-format-rev(1)

From
KHKristoffer 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/
Previous: Kristoffer HaugsbakkNext: Kristoffer Haugsbakk
Message 2 of 3 in “git-diff-tree(1) can already do the important parts of git-format-rev(1)”
  1. Kristoffer HaugsbakkOct 15, 2026
  2. Kristoffer HaugsbakkOct 15, 2026
  3. Kristoffer HaugsbakkOct 17, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.