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

From: Junio C Hamano <[email-masked]>
Date: Mon, 04 Nov 2024 16:22:41 -0800

Christoph Anton Mitterer <[email-masked]> writes:

> 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 ...

> 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.