Thread (2 messages) 2 messages, 2 authors, 2026-02-06

Re: git-am applies commit message diffs

From: Jeff King <hidden>
Date: 2026-02-06 09:24:25

On Fri, Feb 06, 2026 at 09:59:31AM +0100, Florian Weimer wrote:
Isn't the format-patch output already unambiguous because the sequence
of diffs is preceeded by the non-diff statistics section, and only then
the commit message follows?  It's just not possible to process this
correctly in one pass because only at the end of the input, you know
that you have just seen the to-be-applied diffs.
That diffstat is optional, and not parsed by the receiving format-patch
at all. Keep in mind that in the world for which it was originally
designed, people were not necessarily using Git to generate their
emails. They could be patches emailed by random folks using "diff"
themselves.
The other tool to look at is git rebase.  There have been problems with
the lack of "From " encoding in commit messages in the past, which
caused rebases to fail due to commit message contents (but I can totally
imagine that this might have resulted in commit injection with more
carefully crafted commit messages).
It has been a long time since I looked at it, but IIRC we did have a
problem with fidelity of commit message in git-rebase, since it was
based on a format-patch/am pipeline. And we solved it by teaching "git
am" a magic "--rebasing" flag which tells it to ignore the email
contents and find the actual commit in the object database. Gross, but
it works. But of course the same does not work for a true emailed patch,
since the point is that the receiver does not have the commit object
yet.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help