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

Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am

From
Hhuebbe <nathanael.huebbe@informatik.uni-hamburg.de>
Date
Nov 25, 2015, 15:59 UTC
Message-ID
<5655DAE7.2000008@informatik.uni-hamburg.de>
In-Reply-To
<5655D755.8060503@atlas-elektronik.com>
Yes, it looks like the `--keep-non-patch` option works around this.

However, shouldn't that be the default behaviour? I mean, what is the point in stripping stuff that is not proven to be inserted by `git` itself? That's not what I expect a tool to do which I trust.

Cheers, Nathanael

On 11/25/2015 04:44 PM, stefan.naewe@atlas-elektronik.com wrote:
Show 73 quoted lines
> Am 25.11.2015 um 16:29 schrieb huebbe:
>> Description:
>>
>> When applying a patch created via `git format-patch` with `git am`,
>> any prefix of the commit message that's within square brackets is stripped from the commit message.
> 
> As advertised in the man page of 'git am' (or 'git mailinfo' that is).
> 
> Is 'git am --keep-non-patch' what you're looking for ?
> 
>>
>>
>> Reproduction:
>>
>>     $ git log --oneline --decorate --graph --all
>>     * b41514b (HEAD) [baz] baz
>>     | * 5e31740 (master) [bar] bar
>>     |/
>>     * aaf5d34 [foo] foo
>>     $ git format-patch aaf5d34
>>     $ git checkout master
>>     $ git am 0001-baz-baz.patch
>>     $ git log --oneline --decorate --graph --all
>>     * d5161b8 (HEAD, master) baz
>>     * 5e31740 [bar] bar
>>     * aaf5d34 [foo] foo
>>
>> I have omitted all output except for the `git log` output for brevity.
>> As you can see, the commit resulting from `git am` has lost the "[bar]" prefix from its commit message.
>>
>> Looking at the patch,
>>
>>     $ cat 0001-baz-baz.patch
>>     From b41514be8a70fd44052bff0d3ce720373ec9cfd8 Mon Sep 17 00:00:00 2001
>>     From: Nathanael Huebbe <nathanael.huebbe@informatik.uni-hamburg.de>
>>     Date: Wed, 25 Nov 2015 15:28:09 +0100
>>     Subject: [PATCH] [baz] baz
>>
>>     ---
>>      baz | 1 +
>>      1 file changed, 1 insertion(+)
>>      create mode 100644 baz
>>
>>     diff --git a/baz b/baz
>>     new file mode 100644
>>     index 0000000..7601807
>>     --- /dev/null
>>     +++ b/baz
>>     @@ -0,0 +1 @@
>>     +baz
>>     --
>>     2.1.4
>>
>> I see that the commit message contains the "[PATCH]"-prefix that `git am` is supposed to strip,
>> yet it seems to incorrectly continue to also strip the "[baz]"-prefix.
>>
>>
>> Affected versions:
>> I have reproduced the bug with versions 1.9.1, 2.1.4, and 2.6.3
>>
>>
>> Severity:
>> While I do not consider this a high priority bug, it becomes quite irksome in some workflows.
>> In my case, an upstream `svn` repository has the policy of using "[branch-name]" prefixes
>> to the commit messages, which are stripped whenever I transplant a commit using the
>> `git format-patch`/`git am` combination.
>>
>>
>>
> 
> HTH,
>   Stefan
> 
-- 
Please be aware that the enemies of your civil rights and your freedom
are on CC of all unencrypted communication. Protect yourself.
Previous: stefan.naewe@atlas-elektronik.comNext: Jeff King
Message 3 of 10 in “Bug: Incorrect stripping of the [PATCH] prefix in git-am”
  1. huebbeNov 25, 2015
  2. stefan.naewe@atlas-elektronik.comNov 25, 2015
  3. huebbeNov 25, 2015
  4. Jeff KingDec 2, 2015
  5. Stefan BellerDec 2, 2015
  6. Junio C HamanoDec 2, 2015
  7. Junio C HamanoDec 2, 2015
  8. huebbeDec 2, 2015
  9. Jeff KingDec 2, 2015
  10. huebbeDec 3, 2015

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.