{"thread":{"id":"40886","subject":"Bug: Incorrect stripping of the [PATCH] prefix in git-am","startedAt":"2015-11-25T15:29:30Z","lastAt":"2015-12-03T10:32:22Z","messageCount":10,"participants":["huebbe","stefan.naewe@atlas-elektronik.com","Jeff King","Stefan Beller","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"273738","messageId":"5655D3DA.1050403@informatik.uni-hamburg.de","threadId":"40886","inReplyTo":null,"subject":"Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"huebbe","fromEmail":"nathanael.huebbe@informatik.uni-hamburg.de","sentAt":"2015-11-25T15:29:30Z","receivedAt":"2015-11-25T15:29:30Z","isPatch":true,"sender":{"key":"nathanael.huebbe@informatik.uni-hamburg.de","avatar":null},"body":"Description:\n\nWhen applying a patch created via `git format-patch` with `git am`,\nany prefix of the commit message that's within square brackets is stripped from the commit message.\n\n\nReproduction:\n\n    $ git log --oneline --decorate --graph --all\n    * b41514b (HEAD) [baz] baz\n    | * 5e31740 (master) [bar] bar\n    |/\n    * aaf5d34 [foo] foo\n    $ git format-patch aaf5d34\n    $ git checkout master\n    $ git am 0001-baz-baz.patch\n    $ git log --oneline --decorate --graph --all\n    * d5161b8 (HEAD, master) baz\n    * 5e31740 [bar] bar\n    * aaf5d34 [foo] foo\n\nI have omitted all output except for the `git log` output for brevity.\nAs you can see, the commit resulting from `git am` has lost the \"[bar]\" prefix from its commit message.\n\nLooking at the patch,\n\n    $ cat 0001-baz-baz.patch\n    From b41514be8a70fd44052bff0d3ce720373ec9cfd8 Mon Sep 17 00:00:00 2001\n    From: Nathanael Huebbe <nathanael.huebbe@informatik.uni-hamburg.de>\n    Date: Wed, 25 Nov 2015 15:28:09 +0100\n    Subject: [PATCH] [baz] baz\n\n    ---\n     baz | 1 +\n     1 file changed, 1 insertion(+)\n     create mode 100644 baz\n\n    diff --git a/baz b/baz\n    new file mode 100644\n    index 0000000..7601807\n    --- /dev/null\n    +++ b/baz\n    @@ -0,0 +1 @@\n    +baz\n    --\n    2.1.4\n\nI see that the commit message contains the \"[PATCH]\"-prefix that `git am` is supposed to strip,\nyet it seems to incorrectly continue to also strip the \"[baz]\"-prefix.\n\n\nAffected versions:\nI have reproduced the bug with versions 1.9.1, 2.1.4, and 2.6.3\n\n\nSeverity:\nWhile I do not consider this a high priority bug, it becomes quite irksome in some workflows.\nIn my case, an upstream `svn` repository has the policy of using \"[branch-name]\" prefixes\nto the commit messages, which are stripped whenever I transplant a commit using the\n`git format-patch`/`git am` combination.\n\n\n\n-- \nPlease be aware that the enemies of your civil rights and your freedom\nare on CC of all unencrypted communication. Protect yourself.\n\n\n"},{"id":"273739","messageId":"5655D755.8060503@atlas-elektronik.com","threadId":"40886","inReplyTo":"5655D3DA.1050403@informatik.uni-hamburg.de","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"","fromEmail":"stefan.naewe@atlas-elektronik.com","sentAt":"2015-11-25T15:44:21Z","receivedAt":"2015-11-25T15:44:21Z","isPatch":true,"sender":{"key":"stefan.naewe@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4468?v=4"},"body":"Am 25.11.2015 um 16:29 schrieb huebbe:\n> Description:\n> \n> When applying a patch created via `git format-patch` with `git am`,\n> any prefix of the commit message that's within square brackets is stripped from the commit message.\n\nAs advertised in the man page of 'git am' (or 'git mailinfo' that is).\n\nIs 'git am --keep-non-patch' what you're looking for ?\n\n> \n> \n> Reproduction:\n> \n>     $ git log --oneline --decorate --graph --all\n>     * b41514b (HEAD) [baz] baz\n>     | * 5e31740 (master) [bar] bar\n>     |/\n>     * aaf5d34 [foo] foo\n>     $ git format-patch aaf5d34\n>     $ git checkout master\n>     $ git am 0001-baz-baz.patch\n>     $ git log --oneline --decorate --graph --all\n>     * d5161b8 (HEAD, master) baz\n>     * 5e31740 [bar] bar\n>     * aaf5d34 [foo] foo\n> \n> I have omitted all output except for the `git log` output for brevity.\n> As you can see, the commit resulting from `git am` has lost the \"[bar]\" prefix from its commit message.\n> \n> Looking at the patch,\n> \n>     $ cat 0001-baz-baz.patch\n>     From b41514be8a70fd44052bff0d3ce720373ec9cfd8 Mon Sep 17 00:00:00 2001\n>     From: Nathanael Huebbe <nathanael.huebbe@informatik.uni-hamburg.de>\n>     Date: Wed, 25 Nov 2015 15:28:09 +0100\n>     Subject: [PATCH] [baz] baz\n> \n>     ---\n>      baz | 1 +\n>      1 file changed, 1 insertion(+)\n>      create mode 100644 baz\n> \n>     diff --git a/baz b/baz\n>     new file mode 100644\n>     index 0000000..7601807\n>     --- /dev/null\n>     +++ b/baz\n>     @@ -0,0 +1 @@\n>     +baz\n>     --\n>     2.1.4\n> \n> I see that the commit message contains the \"[PATCH]\"-prefix that `git am` is supposed to strip,\n> yet it seems to incorrectly continue to also strip the \"[baz]\"-prefix.\n> \n> \n> Affected versions:\n> I have reproduced the bug with versions 1.9.1, 2.1.4, and 2.6.3\n> \n> \n> Severity:\n> While I do not consider this a high priority bug, it becomes quite irksome in some workflows.\n> In my case, an upstream `svn` repository has the policy of using \"[branch-name]\" prefixes\n> to the commit messages, which are stripped whenever I transplant a commit using the\n> `git format-patch`/`git am` combination.\n> \n> \n> \n\nHTH,\n  Stefan\n-- \n----------------------------------------------------------------\n/dev/random says: Oxymoron: Slow speed.\npython -c \"print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')\" \nGPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9  9666 829B 49C5 9221 27AF\n"},{"id":"273740","messageId":"5655DAE7.2000008@informatik.uni-hamburg.de","threadId":"40886","inReplyTo":"5655D755.8060503@atlas-elektronik.com","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"huebbe","fromEmail":"nathanael.huebbe@informatik.uni-hamburg.de","sentAt":"2015-11-25T15:59:35Z","receivedAt":"2015-11-25T15:59:35Z","isPatch":true,"sender":{"key":"nathanael.huebbe@informatik.uni-hamburg.de","avatar":null},"body":"Yes, it looks like the `--keep-non-patch` option works around this.\n\nHowever, shouldn't that be the default behaviour?\nI mean, what is the point in stripping stuff that is not proven to be inserted by `git` itself?\nThat's not what I expect a tool to do which I trust.\n\nCheers,\nNathanael\n\n\n\nOn 11/25/2015 04:44 PM, stefan.naewe@atlas-elektronik.com wrote:\n> Am 25.11.2015 um 16:29 schrieb huebbe:\n>> Description:\n>>\n>> When applying a patch created via `git format-patch` with `git am`,\n>> any prefix of the commit message that's within square brackets is stripped from the commit message.\n> \n> As advertised in the man page of 'git am' (or 'git mailinfo' that is).\n> \n> Is 'git am --keep-non-patch' what you're looking for ?\n> \n>>\n>>\n>> Reproduction:\n>>\n>>     $ git log --oneline --decorate --graph --all\n>>     * b41514b (HEAD) [baz] baz\n>>     | * 5e31740 (master) [bar] bar\n>>     |/\n>>     * aaf5d34 [foo] foo\n>>     $ git format-patch aaf5d34\n>>     $ git checkout master\n>>     $ git am 0001-baz-baz.patch\n>>     $ git log --oneline --decorate --graph --all\n>>     * d5161b8 (HEAD, master) baz\n>>     * 5e31740 [bar] bar\n>>     * aaf5d34 [foo] foo\n>>\n>> I have omitted all output except for the `git log` output for brevity.\n>> As you can see, the commit resulting from `git am` has lost the \"[bar]\" prefix from its commit message.\n>>\n>> Looking at the patch,\n>>\n>>     $ cat 0001-baz-baz.patch\n>>     From b41514be8a70fd44052bff0d3ce720373ec9cfd8 Mon Sep 17 00:00:00 2001\n>>     From: Nathanael Huebbe <nathanael.huebbe@informatik.uni-hamburg.de>\n>>     Date: Wed, 25 Nov 2015 15:28:09 +0100\n>>     Subject: [PATCH] [baz] baz\n>>\n>>     ---\n>>      baz | 1 +\n>>      1 file changed, 1 insertion(+)\n>>      create mode 100644 baz\n>>\n>>     diff --git a/baz b/baz\n>>     new file mode 100644\n>>     index 0000000..7601807\n>>     --- /dev/null\n>>     +++ b/baz\n>>     @@ -0,0 +1 @@\n>>     +baz\n>>     --\n>>     2.1.4\n>>\n>> I see that the commit message contains the \"[PATCH]\"-prefix that `git am` is supposed to strip,\n>> yet it seems to incorrectly continue to also strip the \"[baz]\"-prefix.\n>>\n>>\n>> Affected versions:\n>> I have reproduced the bug with versions 1.9.1, 2.1.4, and 2.6.3\n>>\n>>\n>> Severity:\n>> While I do not consider this a high priority bug, it becomes quite irksome in some workflows.\n>> In my case, an upstream `svn` repository has the policy of using \"[branch-name]\" prefixes\n>> to the commit messages, which are stripped whenever I transplant a commit using the\n>> `git format-patch`/`git am` combination.\n>>\n>>\n>>\n> \n> HTH,\n>   Stefan\n> \n\n\n-- \nPlease be aware that the enemies of your civil rights and your freedom\nare on CC of all unencrypted communication. Protect yourself.\n\n"},{"id":"273893","messageId":"20151202005826.GE28197@sigill.intra.peff.net","threadId":"40886","inReplyTo":"5655DAE7.2000008@informatik.uni-hamburg.de","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-12-02T00:58:27Z","receivedAt":"2015-12-02T00:58:27Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 25, 2015 at 04:59:35PM +0100, huebbe wrote:\n\n> Yes, it looks like the `--keep-non-patch` option works around this.\n> \n> However, shouldn't that be the default behaviour?\n> I mean, what is the point in stripping stuff that is not proven to be inserted by `git` itself?\n> That's not what I expect a tool to do which I trust.\n\nThe \"[]\" convention is a microformat used by Linux kernel folks. So it's\nnot \"whoops, we are stripping stuff not added by git\". It is respecting\na microformat used by the tool's authors.\n\nThat being said, if we were choosing a default from scratch today, it\nmight go the other way. But we aren't, and we have to deal with the\nburden of breaking existing scripts by flipping it.\n\n-Peff\n"},{"id":"273894","messageId":"CAGZ79kZ8WLzwvsSPCgt4ncfqib479mXuDWQ5cLj0QjmZmR439g@mail.gmail.com","threadId":"40886","inReplyTo":"20151202005826.GE28197@sigill.intra.peff.net","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-12-02T01:10:12Z","receivedAt":"2015-12-02T01:10:12Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Dec 1, 2015 at 4:58 PM, Jeff King <peff@peff.net> wrote:\n> On Wed, Nov 25, 2015 at 04:59:35PM +0100, huebbe wrote:\n>\n>> Yes, it looks like the `--keep-non-patch` option works around this.\n>>\n>> However, shouldn't that be the default behaviour?\n>> I mean, what is the point in stripping stuff that is not proven to be inserted by `git` itself?\n>> That's not what I expect a tool to do which I trust.\n>\n> The \"[]\" convention is a microformat used by Linux kernel folks. So it's\n> not \"whoops, we are stripping stuff not added by git\". It is respecting\n> a microformat used by the tool's authors.\n>\n> That being said, if we were choosing a default from scratch today, it\n> might go the other way. But we aren't, and we have to deal with the\n> burden of breaking existing scripts by flipping it.\n\nDo we as the Git community have a place where we take notes for version 3?\n\nThis sounds perfectly fine (to me at least) to change the default with a major\nversion number as the changelog for major version numbers may even be read\nby kernel devs maintaining such scripts ;)\n\nOr could we even patch that today to have `--keep-non-patch` be default\nlater on by checking for our version number ourselves and deciding upon that\nfor the default?\n\n>\n> -Peff\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"273897","messageId":"xmqqtwo16111.fsf@gitster.mtv.corp.google.com","threadId":"40886","inReplyTo":"20151202005826.GE28197@sigill.intra.peff.net","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-12-02T02:24:10Z","receivedAt":"2015-12-02T02:24:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> The \"[]\" convention is a microformat used by Linux kernel folks. So it's\n> not \"whoops, we are stripping stuff not added by git\". It is respecting\n> a microformat used by the tool's authors.\n>\n> That being said, if we were choosing a default from scratch today, it\n> might go the other way. But we aren't, and we have to deal with the\n> burden of breaking existing scripts by flipping it.\n\nAnd I do think it no longer is sensible to expect that it still is\nkernel-only convention.  Any project that uses e-mail based workflow\nwith Git have known how \"[]\" microformat works, may even have taken\nadvantage of it to build their workflow around it, and flipping the\ndefault will only hurt them.\n\nA project that chooses not to follow the convention can easily tweak\na knob to keep using different conventions, so I do not see anything\nto change here.\n"},{"id":"273898","messageId":"xmqqpoyp60w3.fsf@gitster.mtv.corp.google.com","threadId":"40886","inReplyTo":"CAGZ79kZ8WLzwvsSPCgt4ncfqib479mXuDWQ5cLj0QjmZmR439g@mail.gmail.com","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-12-02T02:27:08Z","receivedAt":"2015-12-02T02:27:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> Do we as the Git community have a place where we take notes for version 3?\n\nI do not think there is, I do think we might need one when a need\narises, and I do not think this topic is one that creates such a\nneed.\n\nAnd I said \"might\" in the second one, based on the experience at\n2.0; we didn't need such a separate place when managing the\nbackward incompatible changes for that release.\n"},{"id":"273908","messageId":"565EE63A.3040006@informatik.uni-hamburg.de","threadId":"40886","inReplyTo":"20151202005826.GE28197@sigill.intra.peff.net","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"huebbe","fromEmail":"nathanael.huebbe@informatik.uni-hamburg.de","sentAt":"2015-12-02T12:38:18Z","receivedAt":"2015-12-02T12:38:18Z","isPatch":true,"sender":{"key":"nathanael.huebbe@informatik.uni-hamburg.de","avatar":null},"body":"On 12/02/2015 01:58 AM, Jeff King wrote:\n> On Wed, Nov 25, 2015 at 04:59:35PM +0100, huebbe wrote:\n> \n>> Yes, it looks like the `--keep-non-patch` option works around this.\n>>\n>> However, shouldn't that be the default behaviour?\n>> I mean, what is the point in stripping stuff that is not proven to be inserted by `git` itself?\n>> That's not what I expect a tool to do which I trust.\n> \n> The \"[]\" convention is a microformat used by Linux kernel folks. So it's\n> not \"whoops, we are stripping stuff not added by git\". It is respecting\n> a microformat used by the tool's authors.\n> \n> That being said, if we were choosing a default from scratch today, it\n> might go the other way. But we aren't, and we have to deal with the\n> burden of breaking existing scripts by flipping it.\n> \n> -Peff\n\nOk, I think I understand the reason for this behavior now.\nHowever, I still believe that the `git format-patch`/`git am` combo\nshould retain the original commit messages by default.\n\nAs such, I would like to ask whether it would be possible/sensible\nto somehow escape square brackets, or mark the beginning\nof the original commit message in the `git format-patch` output?\nThis would allow `git am` to reproduce the exact commit message by default\nwithout breaking the \"[]\" convention.\n\n\nFor example, I could imagine to use this behavior:\n\n  * `git format-patch` produces a message of the format \"[PATCH ...]: original commit message\".\n\n  * `git am` strips the longest prefix that consists entirely of bracketed stuff\n    and ends with the string \"]: \". If that terminator is not found -> old behavior.\n\n  * Users could insert any \"[FOO]\" strings they like before the \":\",\n    which would still be stripped from the commit message by `git am`.\n\nOf course, any such change would not be without pitfalls. With the rule above,\nwe would get \": \" prepended to commit messages if a patch is created with a `git` version\nthat has the change, and applied with an older version that does not know about the terminator.\n\n\nWhat do you guys think? Is there anything I missed?\n\n\nCheers,\nNathanael\n\n\n-- \nPlease be aware that the enemies of your civil rights and your freedom\nare on CC of all unencrypted communication. Protect yourself.\n\n\n"},{"id":"273910","messageId":"20151202154948.GA9525@sigill.intra.peff.net","threadId":"40886","inReplyTo":"565EE63A.3040006@informatik.uni-hamburg.de","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-12-02T15:49:48Z","receivedAt":"2015-12-02T15:49:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 02, 2015 at 01:38:18PM +0100, huebbe wrote:\n\n> As such, I would like to ask whether it would be possible/sensible\n> to somehow escape square brackets, or mark the beginning\n> of the original commit message in the `git format-patch` output?\n> This would allow `git am` to reproduce the exact commit message by default\n> without breaking the \"[]\" convention.\n\nI am not sure why \"git format-patch -k | git am -k\" does not do what you\nwant. That is what those options were added for (and what git-rebase\nuses internally to make sure commit messages are left unmunged).\n\n-Peff\n"},{"id":"273971","messageId":"56601A36.1060803@informatik.uni-hamburg.de","threadId":"40886","inReplyTo":"20151202154948.GA9525@sigill.intra.peff.net","subject":"Re: Bug: Incorrect stripping of the [PATCH] prefix in git-am","fromName":"huebbe","fromEmail":"nathanael.huebbe@informatik.uni-hamburg.de","sentAt":"2015-12-03T10:32:22Z","receivedAt":"2015-12-03T10:32:22Z","isPatch":true,"sender":{"key":"nathanael.huebbe@informatik.uni-hamburg.de","avatar":null},"body":"Dear Peff,\nI have no problem working around this bug/feature.\n\nI just happen to think that the current *default* behaviour\nis not the default behaviour that users have a right to expect:\nI believe that users have every right to expect `git format-patch`/`git am`\nto preserve commit messages perfectly by default.\n\nSince I see that people are using the current behaviour as a feature,\nI tried to come up with an alternative behaviour that would do both:\n\n 1. Respect user assumptions to preserve commit messages by default.\n\n 2. Allow users to prepend stuff when mailing a patch, that will get stripped automatically.\n\nJust because the current behaviour is ... irritating.\n\n\nCheers,\nNathanael\n\n\n\nOn 12/02/2015 04:49 PM, Jeff King wrote:\n> On Wed, Dec 02, 2015 at 01:38:18PM +0100, huebbe wrote:\n> \n>> As such, I would like to ask whether it would be possible/sensible\n>> to somehow escape square brackets, or mark the beginning\n>> of the original commit message in the `git format-patch` output?\n>> This would allow `git am` to reproduce the exact commit message by default\n>> without breaking the \"[]\" convention.\n> \n> I am not sure why \"git format-patch -k | git am -k\" does not do what you\n> want. That is what those options were added for (and what git-rebase\n> uses internally to make sure commit messages are left unmunged).\n> \n> -Peff\n> \n\n\n-- \nPlease be aware that the enemies of your civil rights and your freedom\nare on CC of all unencrypted communication. Protect yourself.\n\n"}]}