git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git mailinfo with patch parser
@ 2019-10-02  4:43 Florian Weimer
  2019-10-02  5:35 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2019-10-02  4:43 UTC (permalink / raw)
  To: git

git mailinfo splits a message into headers, commit message, and patch
text, but does not actually parse the patch text.  As a result, the
patch portion produced by git mailinfo can contain something that
looks like a patch, but actually isn't.

Is there a way to get the patch data, as parsed by git apply or git
am, and dump it back in patch format, without actually applying the
patch to a working tree?

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

* Re: git mailinfo with patch parser
  2019-10-02  4:43 git mailinfo with patch parser Florian Weimer
@ 2019-10-02  5:35 ` Junio C Hamano
  2019-10-02  5:41   ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2019-10-02  5:35 UTC (permalink / raw)
  To: Florian Weimer; +Cc: git

Florian Weimer <fw@deneb.enyo.de> writes:

> git mailinfo splits a message into headers, commit message, and patch
> text, but does not actually parse the patch text.  As a result, the
> patch portion produced by git mailinfo can contain something that
> looks like a patch, but actually isn't.

Yes, mailinfo is about splitting the header, log message and the
remainder, and parsing the remainder to use it as a patch text is
left to the consumer of the "patch" file it produces.

> Is there a way to get the patch data, as parsed by git apply or git
> am, and dump it back in patch format, without actually applying the
> patch to a working tree?

So, "the patch data as used by apply" is what you get from mailinfo.
If it is a patch that applies to what you have in the working tree
and/or the index is something you can/must ask "git apply".  IOW,
when "git mailinfo" stored in $GIT_DIR/rebase-apply/patch the
"remainder" of the message, you could

	git apply --check [--index] $GIT_DIR/rebase-apply/patch

to see if it is an OK patch.  If it is, then there is no need to
further "dump it back in patch format"; what you just fed to "apply
--check" is already in the patch format.




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

* Re: git mailinfo with patch parser
  2019-10-02  5:35 ` Junio C Hamano
@ 2019-10-02  5:41   ` Florian Weimer
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2019-10-02  5:41 UTC (permalink / raw)
  To: git

* Junio C. Hamano:

>> Is there a way to get the patch data, as parsed by git apply or git
>> am, and dump it back in patch format, without actually applying the
>> patch to a working tree?
>
> So, "the patch data as used by apply" is what you get from mailinfo.
> If it is a patch that applies to what you have in the working tree
> and/or the index is something you can/must ask "git apply".  IOW,
> when "git mailinfo" stored in $GIT_DIR/rebase-apply/patch the
> "remainder" of the message, you could
>
> 	git apply --check [--index] $GIT_DIR/rebase-apply/patch
>
> to see if it is an OK patch.  If it is, then there is no need to
> further "dump it back in patch format"; what you just fed to "apply
> --check" is already in the patch format.

Yes, but that requires a fully patched up Git repository containing
the right blobs.

We know from experience that it is easy for humans to misread patches
and fail to notice that certain patch hunks are actually ignored by
git apply and similar tools.  If there was a way to feed the patch
through the parser and serialize it back, these discrepancies would be
more noticeable, I think.  Any data ignored by git apply/git am would
be missing from the output.

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

end of thread, other threads:[~2019-10-02  5:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02  4:43 git mailinfo with patch parser Florian Weimer
2019-10-02  5:35 ` Junio C Hamano
2019-10-02  5:41   ` Florian Weimer

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).