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

Re: help for git format-patch lost diffstat

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 25, 2022, 08:09 UTC
Message-ID
<CAPig+cQsGZ5Uw13vr5r_SZ9APZwovtxSW5N4QGpieHRx1_6zRg@mail.gmail.com>
In-Reply-To
<20220424064114.nwzldz5s2bnkrlu5@kong-HP>
On Sun, Apr 24, 2022 at 9:00 AM FanJun Kong <bh1scw@gmail.com> wrote:
Show 22 quoted lines
> First, I created two commits to a demo project.
>
> when I use command:
> git format-patch --cover-letter -1
> [...]
> FanJun Kong (1):
>   First commit.
>    1.c | 4 ++++
>    1 file changed, 4 insertions(+)
>
> ok, you can see the cover letter has diffstat, just above "--".
>
> git format-patch --cover-letter -2
> [...]
> FanJun Kong (2):
>   First commit.
>   Second commit.
>
> Comparing with last command, I just want to get 2 patches,
> but this time the diffstat is missing.
>
> I am not sure if this is a bug or I miss some options.

This is expected behavior according to this code in make_cover_letter() in builtin/log.c:

    /* We can only do diffstat with a unique reference point */
    if (origin)
        show_diffstat(rev, origin, head);

The problem is that when you format both patches of a two-commit repository, `origin` is NULL because there is no commit preceding the initial commit; the initial commit is the root of the history. Thus, there is nothing prior to the first patch against which to create a diffstat.

I have not investigated, but it may be possible to teach show_diffstat() how to generate a diffstat against the "emptiness" preceding the initial commit, but nobody has done so yet. Perhaps this would be a good project for someone interested in contributing to the project (or perhaps not -- as mentioned, I haven't investigated how hard this would be).

Previous: FanJun KongNext: FanJun Kong
Message 3 of 6 in “help for git format-patch lost diffstat”
  1. FanJun KongApr 24, 2022
  2. FanJun KongApr 24, 2022
  3. Eric SunshineApr 25, 2022
  4. FanJun KongApr 25, 2022
  5. Junio C HamanoApr 25, 2022
  6. Junio C HamanoApr 25, 2022

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.