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

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

Previous: Phillip WoodNext: Matheus Tavares
Message 7 of 13 in “format-patch: warn if commit msg contains a patch delimiter”
  1. format-patch: warn if commit msg contains a patch delimiterMatheus Tavares, Sep 4, 2022
  2. Ævar Arnfjörð BjarmasonSep 5, 2022
  3. René ScharfeSep 5, 2022
  4. 0/2 format-patch: warn if commit msg contains a patch delimiterMatheus Tavares, Sep 7, 2022
  5. 2/2 format-patch: warn if commit msg contains a patch delimiterMatheus Tavares, Sep 7, 2022
  6. Phillip WoodSep 7, 2022
  7. Junio C HamanoSep 7, 2022
  8. Matheus TavaresSep 9, 2022
  9. Junio C HamanoSep 9, 2022
  10. 1/2 patchbreak(), is_scissors_line(): work with a buf/len pairMatheus Tavares, Sep 7, 2022
  11. Phillip WoodSep 7, 2022
  12. Eric SunshineSep 8, 2022
  13. René ScharfeSep 7, 2022

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.