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

Re: Getting clean diff data from git-mailinfo

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 22, 2020, 16:56 UTC
Message-ID
<xmqqftf27e8n.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<xmqqk14e7emp.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> ... then we may have had split (3) into three pieces:
>
>  (3a) material before the pure diff (e.g. diffstat, etc.)
>  (3b) pure diff
>  (3c) trailing junk (e.g. base-commit info, e-mail signature, etc.)
> ...
> So, because there is no such need so far, there is no tool in the
> Git toolbox to split (3) into three pieces.
>
> You're welcome to write one, but the current toolset does not need
> it.

Writing something that reads (3), discarding lines before the first "diff --git", counting lines that appear on "@@ ... @@" line while copying it to the output, repeating the process when you see something other than "diff --git" (i.e. beginning of the patch for the next path) or "@@ ... @@" (i.e. another hunk in the patch for the current path), and discarding the rest may be trivial.

But in practice, people edit their diff [*1*], forgetting the line counts on the "@@ ... @@" lines, and it helps the maintainer to have the whole (3), not only (3b), in a single file to recover from such a broken patch submission.

So adding another tool to produce (3b) only is fine, but an attempt to get rid of (3) and to claim that (3b) replaces the need for (3) is highly discouraged.

Thanks.
[Footnote]
*1* Even when people edit without changing the line numbers (imagine
    a typofix on a '+' line), I saw that "patch" mode of Emacs broke
    the line count on "@@ ...@@" line of the last hunk when the
    patch ends with certain patterns.
Previous: Junio C HamanoNext: Andreas Schwab
Message 3 of 4 in “Getting clean diff data from git-mailinfo”
  1. Konstantin RyabitsevFeb 21, 2020
  2. Junio C HamanoFeb 22, 2020
  3. Junio C HamanoFeb 22, 2020
  4. Andreas SchwabFeb 22, 2020

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.