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

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
Previous: Christoph Anton MittererNext: Christoph Anton Mitterer
Message 6 of 10 in “git format-patch escaping issues in the patch format”
  1. Christoph Anton MittererNov 4, 2024
  2. Kristoffer HaugsbakkNov 4, 2024
  3. Christoph Anton MittererNov 5, 2024
  4. Kristoffer HaugsbakkNov 5, 2024
  5. Christoph Anton MittererNov 5, 2024
  6. Jeff KingNov 4, 2024
  7. Christoph Anton MittererNov 5, 2024
  8. Jeff KingNov 5, 2024
  9. Junio C HamanoNov 5, 2024
  10. Christoph Anton MittererNov 5, 2024

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.