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

Re: git am fails because of weird text in commit log

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 13, 2021, 20:33 UTC
Message-ID
<xmqqzh1cwp9q.fsf@gitster.c.googlers.com>
In-Reply-To
<20210113085846-mutt-send-email-mst@kernel.org>
"Michael S. Tsirkin" <mst@redhat.com> writes:
> So someone sends me a patch with --- in the commit log, like this below.
> Result: git am gets confused and can't apply the patch.
Quite understandable.
> Shouldn't git format-patch at least complain about commit log
> like this, if not mangle it in some way?

It probably is too early to warn, mangle or quote in "git commit". I agree with you that "git format-patch" would be the best step in a typical workflow to warn, mangle or quote.

The solution would probably begin with identifying the lines in the commit log that mailinfo.c::patchbreak() considers the beginning of the patch part. After finding such a line:

 - Warning is easy.  
 - Mangling the line by prefixing something like " " in front of it
   would also be easy.
 - Quoting thru to the end of "patch that shouldn't have been there"
   in possibly a reversible way is probably too hard.

Mangling or quoting should be hidden behind an option, I would think.

Patches welcome.
Thanks.
Previous: Michael S. Tsirkin
Message 2 of 2 in “git am fails because of weird text in commit log”
  1. Michael S. TsirkinJan 13, 2021
  2. Junio C HamanoJan 13, 2021

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.