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.