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

Re: git format-patch escaping issues in the patch format

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 5, 2024, 00:22 UTC
Message-ID
<xmqqttcmv8a6.fsf@gitster.g>
In-Reply-To
<ca13705ae4817ffba16f97530637411b59c9eb19.camel@scientia.org>
Christoph Anton Mitterer <calestyo@scientia.org> writes:
Show 8 quoted lines
> There seems unfortunately only little (written) definition of that
> format, git-format-patch(1) merely says it's in UNIX mailbox format
> (which itself is, AFAIK, not really formally defined).
>
>
> Anyway, it seems to turn out, that no escaping is done for the commit
> message in the patch format and that this can cause actual breakage
> with valid commit messages.
Yes, so ...
Show 5 quoted lines
> Consider the following example:
>    ~/test/foo$ git commit -m "msg1
>    
>    From 0000000000000000000000000000000061603705 Mon Sep 17 00:00:00 2001
>    --
... this falls squarely into "if it hurts, don't do it" category.

A commonly used trick, when you are working on Git and have to include such a line in the commit log message, e.g., when you discuss how the output produced by "git log --format=email" looks like, is to indent such lines in the paragraph you talk about them, e.g.

    In a format-patch output file, the contents of each commit
    begins with
	From 8f8d6eee531b3fa1a8ef14f169b0cb5035f7a772 Mon Sep 17 00:00:00 2001
    where the string 8f8d... is replaced with the name of the commit
    object the patch was taken from.
Previous: Jeff KingNext: Christoph Anton Mitterer
Message 9 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.