Re: [PATCH v2 2/2] format-patch: warn if commit msg contains a patch delimiter
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 7, 2022, 18:36 UTC
- Message-ID
- <xmqqa67buj4m.fsf@gitster.g>
- In-Reply-To
- <4d750ff2-9df5-504f-9972-59b082000db0@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 22 quoted lines
> Hi Matheus > > On 07/09/2022 15:44, Matheus Tavares wrote: >> When applying a patch, `git am` looks for special delimiter strings >> (such as "---") to know where the message ends and the actual diff >> starts. If one of these strings appears in the commit message itself, >> `am` might get confused and fail to apply the patch properly. This has >> already caused inconveniences in the past [1][2]. To help avoid such >> problem, let's make `git format-patch` warn on commit messages >> containing one of the said strings. > > Thanks for working on this, having a warning for this is a useful > addition. If the user embeds a diff in their commit message then they > will receive three warnings > > warning: commit message has a patch delimiter: 'diff --git a/file b/file' > warning: commit message has a patch delimiter: '--- file' > warning: git am might fail to apply this patch. Consider indenting the > offending lines. > > I guess it's helpful to show all the lines that are considered > delimiters but it gets quite noisy.
True. I wonder if automatically indenting these lines is an option ;-)
Show 7 quoted lines
>> +
>> + if (found_delimiter) {
>> + warning(_("git am might fail to apply this patch. "
>> + "Consider indenting the offending lines."));
>
> The message says the patch might fail to apply, but isn't it
> guaranteed to fail?Worse is it may apply a wrong thing (i.e. an illustration patch in the proposed log message gets applied and committed with a truncated log message).