Re: Getting clean diff data from git-mailinfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Konstantin Ryabitsev <konstantin@xxxxxxxxxxxxxxxxxxx> writes:

> Is there a git-native command to further clean up the "patch" file to 
> get just diff contents (i.e. as returned by "git diff" after this patch 
> is applied)?

There isn't one, as Git did not need one ;-)

The "git am" toolchain is tasked to take a reasonably formatted
e-mailed patch generated by tools other people use.  When fed a
piece of e-mail, after it was split out of a mailbox by the "git
mailsplit" program, the "git mailinfo" program is asked to

 (1) gather metainfo for author identity
 (2) gather commit log message material
 (3) collect the input for "git apply"

The e-mail header is parsed for (1) and the first line of (2), and
then the e-mail body is scanned to find the boundary between (2) and
(3), and this is done in order to avoid cruft at the end of (2) as
much as possible, because (2) is something a human user has to clean
up while applying, as opposed to (3) that is mechanically processed.
For that, the line between (2) and (3) is drawn:

 (a) at "---\n" line, for output by "git format-patch";

 (b) at "Index: " line, that often comes from CVS repository;

 (c) at "diff -" line, that can catch handmade patch e-mail using
     GNU and BSD diff.

And that is why we throw the diffstat and commentary to maintainer
that are written after the "---\n" line but before the diff in (3).

Now, if "git apply" were less smart and required a pure diff without
anything else wround it as its input, 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.)

But "git apply" was designed to be usable on the whole of plain text
e-mail, roughly as a "GNU diff" replacement, it does not require (3a)
and (3c) cleansed out from its input.

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.

Thanks.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux