Re: git format-patch escaping issues in the patch format
- From
Jeff King <peff@peff.net>
- Date
- Nov 4, 2024, 23:54 UTC
- Message-ID
- <20241104235432.GB3017597@coredump.intra.peff.net>
- In-Reply-To
- <ca13705ae4817ffba16f97530637411b59c9eb19.camel@scientia.org>
On Mon, Nov 04, 2024 at 08:24:14PM +0100, Christoph Anton Mitterer wrote:
> 2. The format-patch for that looks already suspicious: > - The From line is not escaped (as some variants of mbox would do, > some properly some, causing corruption by the escaping with > > itself).
As you note, the mbox format is not well defined. :) The variant with ">"-quoting of "From" lines is often called "mboxrd", and you can get it with the "--format=mboxrd" option.
> - What the format may think of as a separator after the commit > message (namely the ---) cannot be used as that either, as a --- > in the commit message is again not escaped.
For this, though, I don't think there is any solution. The receiving side of "git am" does not know of any unquoting mechanism. So even if you wanted to quote it, you could not get a lossless transmission of the commit message.
This does occasionally cause confusion. Especially if you include an unindented diff in your commit message, which similarly (and intentionally) triggers the "---" detection. But I think it's one of those things that just doesn't come up often enough for anybody to have cared about trying to address.
-Peff