{"thread":{"id":"28397","subject":"Problems with format-patch UTF-8 and a missing second empty line","startedAt":"2011-09-15T09:45:15Z","lastAt":"2011-09-15T20:33:36Z","messageCount":6,"participants":["Ingo Ruhnke","Jeff King","Alexey Shumkin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"175565","messageId":"CAHz1FYgPuMHLC+f2mFqD73=NGXQSStRPDOsiCy-HtaWKbHu7NQ@mail.gmail.com","threadId":"28397","inReplyTo":null,"subject":"Problems with format-patch UTF-8 and a missing second empty line","fromName":"Ingo Ruhnke","fromEmail":"grumbel@gmail.com","sentAt":"2011-09-15T09:45:15Z","receivedAt":"2011-09-15T09:45:15Z","isPatch":false,"sender":{"key":"grumbel@gmail.com","avatar":null},"body":"Creating a patch of a commit including UTF-8 and no empty second line,\nlike this:\n\nmkdir foobar\ncd foobar\ngit init\necho \"Hello World\" > file\ngit add file\ngit commit -m \"ÄÖÜ\nÄÖÜ\" file\ngit format-patch --root HEAD --stdout\n\nResults in this:\n\nFrom f4f889bad560c479a70fbf5f70a4239576001262 Mon Sep 17 00:00:00 2001\nFrom: Ingo Ruhnke <grumbel@gmail.com>\nDate: Thu, 15 Sep 2011 11:25:11 +0200\nSubject: [PATCH] =?UTF-8?q?=C3=84=C3=96=C3=9C\n=20=C3=84=C3=96=C3=9C?=\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n...\n\nTrying to apply the patch then results in this:\n\n$ git am /tmp/foobar/0001-.patch\nApplying: =?UTF-8?q?=C3=84=C3=96=C3=9C\napplying to an empty history\n$ git log\ncommit 6f27fc51a8c52fdb595131a934d8d56c9df3b5c0\nAuthor: Ingo Ruhnke <grumbel@gmail.com>\nDate:   Thu Sep 15 11:27:47 2011 +0200\n\n    =?UTF-8?q?=C3=84=C3=96=C3=9C\n\n    =20=C3=84=C3=96=C3=9C?=\n    MIME-Version: 1.0\n    Content-Type: text/plain; charset=UTF-8\n    Content-Transfer-Encoding: 8bit\n\nThe UTF-8 stuff doesn't get decoded and the log message ends up broken.\n\nThe problem seems to already start with just the lack of an empty second line:\n\nmkdir foobar\ncd foobar\ngit init\necho \"Hello World\" > file\ngit add file\ngit commit -m \"ABC\nABC\" file\ngit format-patch --root HEAD --stdout\n\nFrom 3abc0e59abc4c9343d22e79575e02910073d1013 Mon Sep 17 00:00:00 2001\nFrom: Ingo Ruhnke <grumbel@gmail.com>\nDate: Thu, 15 Sep 2011 11:31:03 +0200\nSubject: [PATCH] ABC\n ABC\n\n$ git am /tmp/foobar/0001-ABC.patch\nApplying: ABC ABC\napplying to an empty history\ningo@duo:/tmp/5/bar$ git log | cat\ncommit eb8a9e9a1421ae6d930d99bfb8f2eab47349c387\nAuthor: Ingo Ruhnke <grumbel@gmail.com>\nDate:   Thu Sep 15 11:31:03 2011 +0200\n\n    ABC ABC\n\nHere the newline between ABC\\nABC gets stripped out and replaced with\na space when transferring the commit with format-patch from one\nrepository to another.\n\nInserting an empty second line in the commit message makes both\nproblems go away.\n\nAnother small issue is that the filename of the patch will strip out\nany UTF-8 characters, Thus a commit message of \"123Äöü456\" will result\nin \"0001-123-456.patch\".\n\nThe problems happen with git version 1.7.4.1 (4b5eac7f0) on Ubuntu 11.04.\n\n-- \nBlog:     http://grumbel.blogspot.com/\nJabberID: xmpp:grumbel@jabber.org\nICQ:      59461927\n"},{"id":"175583","messageId":"20110915151734.GA18305@sigill.intra.peff.net","threadId":"28397","inReplyTo":"CAHz1FYgPuMHLC+f2mFqD73=NGXQSStRPDOsiCy-HtaWKbHu7NQ@mail.gmail.com","subject":"Re: Problems with format-patch UTF-8 and a missing second empty line","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-15T15:17:34Z","receivedAt":"2011-09-15T15:17:34Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 15, 2011 at 11:45:15AM +0200, Ingo Ruhnke wrote:\n\n> Creating a patch of a commit including UTF-8 and no empty second line,\n> like this:\n> [...]\n> Results in this:\n> [...]\n> Subject: [PATCH] =?UTF-8?q?=C3=84=C3=96=C3=9C\n> =20=C3=84=C3=96=C3=9C?=\n>[....]\n> The problems happen with git version 1.7.4.1 (4b5eac7f0) on Ubuntu 11.04.\n\nI'm pretty sure I fixed this in a1f6baa, which is in v1.7.4.4 and later.\n\n-Peff\n"},{"id":"175598","messageId":"20110915185033.GA17016@sigill.intra.peff.net","threadId":"28397","inReplyTo":"20110915224456.14410ed8@zappedws","subject":"Re: Problems with format-patch UTF-8 and a missing second empty line","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-15T18:50:33Z","receivedAt":"2011-09-15T18:50:33Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"[resending with git@vger cc'd; please keep discussion on list]\n\nOn Thu, Sep 15, 2011 at 10:44:56PM +0400, Alexey Shumkin wrote:\n\n> > On Thu, Sep 15, 2011 at 11:45:15AM +0200, Ingo Ruhnke wrote:\n> > \n> > > Creating a patch of a commit including UTF-8 and no empty second\n> > > line, like this:\n> > > [...]\n> > > Results in this:\n> > > [...]\n> > > Subject: [PATCH] =?UTF-8?q?=C3=84=C3=96=C3=9C\n> > > =20=C3=84=C3=96=C3=9C?=\n> > >[....]\n> > > The problems happen with git version 1.7.4.1 (4b5eac7f0) on Ubuntu\n> > > 11.04.\n> > \n> > I'm pretty sure I fixed this in a1f6baa, which is in v1.7.4.4 and\n> > later.\n> \n> I reproduced this bug with the latest git (v1.7.6.3)\n> It seems to me this is not the \"git format-patch\" bug\n> but \"git am\"'s one. (But it is only the supposition)\n\nCan you be more specific about what you tested? Running Ingo's snippet\nwith a more recent git produces:\n\n  Subject: [PATCH] =?UTF-8?q?=C3=84=C3=96=C3=9C=20=C3=84=C3=96=C3=9C?=\n\nwhich is right (and \"git am\", new or old, will apply it just fine).\n\nBut there may be a different, related bug lurking somewhere.\n\n-Peff\n"},{"id":"175599","messageId":"20110915190132.GA17027@sigill.intra.peff.net","threadId":"28397","inReplyTo":"CAHz1FYgPuMHLC+f2mFqD73=NGXQSStRPDOsiCy-HtaWKbHu7NQ@mail.gmail.com","subject":"Re: Problems with format-patch UTF-8 and a missing second empty line","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-15T19:01:32Z","receivedAt":"2011-09-15T19:01:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Sep 15, 2011 at 11:45:15AM +0200, Ingo Ruhnke wrote:\n\n> Creating a patch of a commit including UTF-8 and no empty second line,\n> like this:\n\nI already responded about the bug with utf8-encoded subjects, but let me\naddress the second half of your mail, too:\n\n> Here the newline between ABC\\nABC gets stripped out and replaced with\n> a space when transferring the commit with format-patch from one\n> repository to another.\n\nThis is by design. Git commit messages are intended to have a\nsingle-line subject, followed by a blank line, followed by more\nelaboration. A multi-line subject is treated as a single line that has\nbeen line-broken, and is subject to being reflowed onto a single line.\nThis is done to help with commits imported from other version control\nsystems which don't follow this pattern (the other option is truncating\nthe subject and putting the other lines into the \"body\", but that often\nends up quite unreadable).\n\nIf you really want to retain the newlines across \"format-patch | am\",\nuse the \"-k\" option of both to preserve the subject (I don't recall the\ndetails, but I think you need a more recent version of git for\nformat-patch to correctly encode this, but \"am\" can be from any\nversion).\n\n> Another small issue is that the filename of the patch will strip out\n> any UTF-8 characters, Thus a commit message of \"123Äöü456\" will result\n> in \"0001-123-456.patch\".\n\nYes, it's an attempt to strip out characters that some filesystems might\nnot support well. We could probably enable high-bit characters with a\nconfig option (maybe even just using core.quotepath).\n\n-Peff\n"},{"id":"175601","messageId":"20110916000515.1dfc5665@zappedws","threadId":"28397","inReplyTo":"20110915185033.GA17016@sigill.intra.peff.net","subject":"Re: Problems with format-patch UTF-8 and a missing second empty line","fromName":"Alexey Shumkin","fromEmail":"zapped@mail.ru","sentAt":"2011-09-15T20:05:15Z","receivedAt":"2011-09-15T20:05:15Z","isPatch":false,"sender":{"key":"alex.crezoff@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1183752?v=4"},"body":"> > \n> > I reproduced this bug with the latest git (v1.7.6.3)\n> > It seems to me this is not the \"git format-patch\" bug\n> > but \"git am\"'s one. (But it is only the supposition)\n> \n> Can you be more specific about what you tested? Running Ingo's snippet\n> with a more recent git produces:\n> \n>   Subject: [PATCH] =?UTF-8?q?=C3=84=C3=96=C3=9C=20=C3=84=C3=96=C3=9C?=\n> \n> which is right (and \"git am\", new or old, will apply it just fine).\n> \n> But there may be a different, related bug lurking somewhere.\n> \n> -Peff\n> \nthis is my steps (log from terminal)\n\n$ mkdir git-format-patch\nInitialized empty Git repository\nin /home/Alex/tmp/git-format-patch/.git/\n\n$ cd git-format-patch\n\n$ echo file content > file\n\n$ git add -vf file\nadd 'file'\n\n$ git commit -a -m 'коммит: строка-1\n> коммит: строка-2'\n\n[master (root-commit) 7ede929] коммит: строка-1 коммит: строка-2\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 file\n\n$ git log\ncommit 7ede9291cf2d160721bcd8362d8d0f6c6e28cf29\nAuthor: Alexey Shumkin <zapped@mail.ru>\nDate:   Thu Sep 15 23:18:26 2011 +0400\n\n    коммит: строка-1\n    коммит: строка-2\n\n$ git format-patch --root HEAD\n0001-1.patch\n\n$ cat 0001-1.patch \nFrom 7ede9291cf2d160721bcd8362d8d0f6c6e28cf29 Mon Sep 17 00:00:00 2001\nFrom: Alexey Shumkin <zapped@mail.ru>\nDate: Thu, 15 Sep 2011 23:18:26 +0400\nSubject: [PATCH]\n=?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82:=20=D1=81=D1?=\n=?UTF-8?q?=82=D1=80=D0=BE=D0=BA=D0=B0-1=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1?=\n=?UTF-8?q?=82:=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0-2?=\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\n---\n file |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 file\n\ndiff --git a/file b/file\nnew file mode 100644\nindex 0000000..dd59d09\n--- /dev/null\n+++ b/file\n@@ -0,0 +1 @@\n+file content\n-- \n1.7.6.3.4.gf71f\n\n$ git init ../git-format-patch-am\nInitialized empty Git repository\nin /home/Alex/tmp/git-format-patch-am/.git/\n\n$ cd ../git-format-patch-am\n\n$ git am < ../git-format-patch/0001-1.patch\nApplying: коммит: строка-1 коммит: строка-2\napplying to an empty history\n\n$ git log\ncommit 9856238e06d4ca8faeefc48e5c80e8ef7bd34195\nAuthor: Alexey Shumkin <zapped@mail.ru>\nDate:   Thu Sep 15 23:18:26 2011 +0400\n\n    коммит: строка-1 коммит: строка-2\n\n$ git --version\ngit version 1.7.6.3.4.gf71f\n\n\n\nBut as you said\n>>This is by design. Git commit messages are intended to have a\n>>single-line subject, followed by a blank line, followed by more\n>>elaboration\n\nand solved with \"-k\" for both \"format-patch\" and \"am\" commands\n"},{"id":"175604","messageId":"20110915203336.GA17566@sigill.intra.peff.net","threadId":"28397","inReplyTo":"20110916000515.1dfc5665@zappedws","subject":"Re: Problems with format-patch UTF-8 and a missing second empty line","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-15T20:33:36Z","receivedAt":"2011-09-15T20:33:36Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Sep 16, 2011 at 12:05:15AM +0400, Alexey Shumkin wrote:\n\n> But as you said\n> >>This is by design. Git commit messages are intended to have a\n> >>single-line subject, followed by a blank line, followed by more\n> >>elaboration\n> \n> and solved with \"-k\" for both \"format-patch\" and \"am\" commands\n\nOK, that makes sense to me, then. I didn't read Ingo's first message\ncarefully enough, but your response made me scratch my head and read it\nagain. Thanks for the sanity check.\n\n-Peff\n"}]}