{"thread":{"id":"55899","subject":"[Bug report] git format-patch + git am doesn't preserve original commit message","startedAt":"2021-06-10T15:05:56Z","lastAt":"2021-06-10T16:29:44Z","messageCount":4,"participants":["Nikita Bobko","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"427022","messageId":"CAMJzOtzu-fKxtseSPQ8riTC-kfg1CphnXN=EN-rnxVo85dZvFw@mail.gmail.com","threadId":"55899","inReplyTo":null,"subject":"[Bug report] git format-patch + git am doesn't preserve original commit message","fromName":"Nikita Bobko","fromEmail":"nikitabobko@gmail.com","sentAt":"2021-06-10T15:04:58Z","receivedAt":"2021-06-10T15:05:56Z","isPatch":false,"sender":{"key":"nikitabobko@gmail.com","avatar":null},"body":"Steps to reproduce:\n```\ngit init\ngit commit --allow-empty -m 'root'\necho foo > foo\ngit add .\ngit commit -m '[tag] foo'\ngit checkout @~\ngit format-patch master~..master\ncat 0001-tag-foo.patch | git am\n```\nExpected: commit message generated by `git am` is `[tag] foo`\nActual: commit message generated by `git am` is `foo`\n\n[System Info]\ngit version:\ngit version 2.31.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.4.98-1-lts #1 SMP Sat, 13 Feb 2021 19:22:14 +0000 x86_64\ncompiler info: gnuc: 10.2\nlibc info: glibc: 2.33\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\n"},{"id":"427023","messageId":"YMIrkBiCpUXcUwsW@coredump.intra.peff.net","threadId":"55899","inReplyTo":"CAMJzOtzu-fKxtseSPQ8riTC-kfg1CphnXN=EN-rnxVo85dZvFw@mail.gmail.com","subject":"Re: [Bug report] git format-patch + git am doesn't preserve original commit message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-06-10T15:11:12Z","receivedAt":"2021-06-10T15:11:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jun 10, 2021 at 05:04:58PM +0200, Nikita Bobko wrote:\n\n> Steps to reproduce:\n> ```\n> git init\n> git commit --allow-empty -m 'root'\n> echo foo > foo\n> git add .\n> git commit -m '[tag] foo'\n> git checkout @~\n> git format-patch master~..master\n> cat 0001-tag-foo.patch | git am\n> ```\n> Expected: commit message generated by `git am` is `[tag] foo`\n> Actual: commit message generated by `git am` is `foo`\n\nThis is working as intended. See the \"-k\" option of git-am and\ngit-mailinfo (and also \"-b\" for mailinfo).\n\n-Peff\n"},{"id":"427029","messageId":"CAMJzOtx9D7KthsUi7eLcmz7rszOQh8t=-VhXeOGDX1CMV1iERQ@mail.gmail.com","threadId":"55899","inReplyTo":"YMIrkBiCpUXcUwsW@coredump.intra.peff.net","subject":"Re: [Bug report] git format-patch + git am doesn't preserve original commit message","fromName":"Nikita Bobko","fromEmail":"nikitabobko@gmail.com","sentAt":"2021-06-10T15:36:43Z","receivedAt":"2021-06-10T15:36:25Z","isPatch":false,"sender":{"key":"nikitabobko@gmail.com","avatar":null},"body":"Oh, I see, thank you, it works.\n\nBut actually, I am not sure that it's \"expected\" behavior. I would\nexpect git to preserve original message by default without any\nadditional flags. Shouldn't `--keep-non-patch` flag in `git am` be\nenabled by default then?\n\nOn Thu, Jun 10, 2021 at 5:11 PM Jeff King <peff@peff.net> wrote:\n>\n> On Thu, Jun 10, 2021 at 05:04:58PM +0200, Nikita Bobko wrote:\n>\n> > Steps to reproduce:\n> > ```\n> > git init\n> > git commit --allow-empty -m 'root'\n> > echo foo > foo\n> > git add .\n> > git commit -m '[tag] foo'\n> > git checkout @~\n> > git format-patch master~..master\n> > cat 0001-tag-foo.patch | git am\n> > ```\n> > Expected: commit message generated by `git am` is `[tag] foo`\n> > Actual: commit message generated by `git am` is `foo`\n>\n> This is working as intended. See the \"-k\" option of git-am and\n> git-mailinfo (and also \"-b\" for mailinfo).\n>\n> -Peff\n"},{"id":"427034","messageId":"YMI99TBbZ1zCFE1V@coredump.intra.peff.net","threadId":"55899","inReplyTo":"CAMJzOtx9D7KthsUi7eLcmz7rszOQh8t=-VhXeOGDX1CMV1iERQ@mail.gmail.com","subject":"Re: [Bug report] git format-patch + git am doesn't preserve original commit message","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-06-10T16:29:41Z","receivedAt":"2021-06-10T16:29:44Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jun 10, 2021 at 05:36:43PM +0200, Nikita Bobko wrote:\n\n> Oh, I see, thank you, it works.\n> \n> But actually, I am not sure that it's \"expected\" behavior. I would\n> expect git to preserve original message by default without any\n> additional flags. Shouldn't `--keep-non-patch` flag in `git am` be\n> enabled by default then?\n\nI'd be hesitant to change that, since it would break any communities\nusing other tags. I think 17635fc900 (mailinfo: -b option keeps\n[bracketed] strings that is not a [PATCH] marker, 2009-07-15) has some\nexamples.\n\nIn your example, I think passing \"-k\" to both git-format-patch and\ngit-am is the right solution. But presumably that's a toy example. In\nthe real world, the person running \"am\" is probably not the same as the\none running format-patch (and if it is, probably something like\ncherry-pick is a better solution anyway).\n\n-Peff\n"}]}