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