{"thread":{"id":"46578","subject":"[BUG] git am sometimes unable to apply git format-patch output file","startedAt":"2017-08-12T16:03:36Z","lastAt":"2017-08-16T07:46:15Z","messageCount":4,"participants":["Soul Trace","Torsten Bögershausen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"326225","messageId":"a6e69bd1-b91f-3150-c3a6-9378793e5e43@list.ru","threadId":"46578","inReplyTo":null,"subject":"[BUG] git am sometimes unable to apply git format-patch output file","fromName":"Soul Trace","fromEmail":"s-trace@list.ru","sentAt":"2017-08-12T16:02:59Z","receivedAt":"2017-08-12T16:03:36Z","isPatch":false,"sender":{"key":"s-trace@list.ru","avatar":null},"body":"Hello.\n\nUsing git i have found that git am command may sometimes fail to apply \npatch file which was created by the git am command.\n\n\nSteps to reproduce:\n\n# 1. Clone test repository:\n\ngit clone https://github.com/S-trace/git_am_bug_test.git\n\n# 2. Format patch file for last commit:\n\ngit format-patch HEAD~\n\n# 3. Go to previous commit:\n\ngit checkout HEAD~\n\n# 4. Apply back patch file created in step 2:\n\ngit am 0001-UPDATE-Update-ascend_MOGOLIA_ULG_normal.xml.patch\n\nThe git am command fails on my machine with the following error message:\n\nApplying: Update ascend_MOGOLIA_ULG_normal.xml\n.git/rebase-apply/patch:6522: trailing whitespace.\n     </scene>\nerror: patch failed: ascend_MOGOLIA_ULG_normal.xml:1\nerror: ascend_MOGOLIA_ULG_normal.xml: patch does not apply\nPatch failed at 0001 Update ascend_MOGOLIA_ULG_normal.xml\nThe copy of the patch that failed is found in: .git/rebase-apply/patch\nWhen you have resolved this problem, run \"git am --continue\".\nIf you prefer to skip this patch, run \"git am --skip\" instead.\nTo restore the original branch and stop patching, run \"git am --abort\".\n\n\nBut patch command can handle this patch file:\n\npatch -p1 -i 0001-UPDATE-Update-ascend_MOGOLIA_ULG_normal.xml.patch\n\n\nVersions information:\n\ngit --version\ngit version 2.11.0\n\npatch --version\nGNU patch 2.7.5\nCopyright (C) 2003, 2009-2012 Free Software Foundation, Inc.\nCopyright (C) 1988 Larry Wall\n\nLicense GPLv3+: GNU GPL version 3 or later \n<http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\nWritten by Larry Wall and Paul Eggert\n\nuname -a\nLinux omen 4.10.0-26-generic #30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017 \nx86_64 x86_64 x86_64 GNU/Linux\n\nlsb_release -a\nNo LSB modules are available.\nDistributor ID: Ubuntu\nDescription:    Ubuntu 17.04\nRelease:        17.04\nCodename:       zesty\n\n\nThank you.\n\n"},{"id":"326226","messageId":"20170812162023.GA21045@tor.lan","threadId":"46578","inReplyTo":"a6e69bd1-b91f-3150-c3a6-9378793e5e43@list.ru","subject":"Re: [BUG] git am sometimes unable to apply git format-patch output file","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2017-08-12T16:20:23Z","receivedAt":"2017-08-12T16:20:29Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sat, Aug 12, 2017 at 07:02:59PM +0300, Soul Trace wrote:\n> Hello.\n> \n> Using git i have found that git am command may sometimes fail to apply patch\n> file which was created by the git am command.\n> \n> \n> Steps to reproduce:\n\nExcellent, thanks so much for the detailed bug report.\nThis kind of information is really appreciated.\n\nWhy did I say excellent ?\nBecause I am working on a patch, which -should- fix exactly this kind of issues.\nI send out a patch earlier this day, but it doesn't fix your issue, even if it should.\nI hope to have a fix soonish.\n"},{"id":"326227","messageId":"20170812170136.GB21045@tor.lan","threadId":"46578","inReplyTo":"20170812162023.GA21045@tor.lan","subject":"Re: [BUG] git am sometimes unable to apply git format-patch output file","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2017-08-12T17:01:36Z","receivedAt":"2017-08-12T17:07:09Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Sat, Aug 12, 2017 at 06:20:23PM +0200, Torsten Bögershausen wrote:\n> On Sat, Aug 12, 2017 at 07:02:59PM +0300, Soul Trace wrote:\n> > Hello.\n> > \n> > Using git i have found that git am command may sometimes fail to apply patch\n> > file which was created by the git am command.\n> > \n> > \n> > Steps to reproduce:\n> \n> Excellent, thanks so much for the detailed bug report.\n> This kind of information is really appreciated.\n> \n> Why did I say excellent ?\n> Because I am working on a patch, which -should- fix exactly this kind of issues.\n> I send out a patch earlier this day, but it doesn't fix your issue, even if it should.\n> I hope to have a fix soonish.\n\nI need to correct mysef, a litte bit, this doesn't seem to be a bug, but a feature.\nThere are 2 things to be noticed:\n- The xml file has been commited with CRLF\n- git am strips the CR (because they -may- have been added by a mail program)\n\nThere are 2 different solutions:\na) Use git am --keep-cr\nb) \"Normalize\" the xml file(s), and commit them to have LF in the repo,\n    they can still have CRLF in the work tree, if needed.\n    This is done by\n    echo \"*.xml text\" >>.gitattributes\n    touch *.xml\n    git add *.xml .gitattributes\n    git commit -m \"Normalize xml files\"\n\n\nIf you really need the xml files with CRLF, use this line instead:\n    echo \"*.xml eol=CRLF\" >>.gitattributes\n\nHTH\n/Torsten\n"},{"id":"326491","messageId":"71432224-5ec4-7f48-7e9f-c0a69a75efad@list.ru","threadId":"46578","inReplyTo":"20170812170136.GB21045@tor.lan","subject":"Re: [BUG] git am sometimes unable to apply git format-patch output file","fromName":"Soul Trace","fromEmail":"s-trace@list.ru","sentAt":"2017-08-16T07:45:43Z","receivedAt":"2017-08-16T07:46:15Z","isPatch":false,"sender":{"key":"s-trace@list.ru","avatar":null},"body":"12.08.2017 20:01, Torsten Bögershausen пишет:\n> On Sat, Aug 12, 2017 at 06:20:23PM +0200, Torsten Bögershausen wrote:\n>> On Sat, Aug 12, 2017 at 07:02:59PM +0300, Soul Trace wrote:\n>>> Hello.\n>>>\n>>> Using git i have found that git am command may sometimes fail to apply patch\n>>> file which was created by the git am command.\n>>>\n>>>\n>>> Steps to reproduce:\n>> Excellent, thanks so much for the detailed bug report.\n>> This kind of information is really appreciated.\n>>\n>> Why did I say excellent ?\n>> Because I am working on a patch, which -should- fix exactly this kind of issues.\n>> I send out a patch earlier this day, but it doesn't fix your issue, even if it should.\n>> I hope to have a fix soonish.\n> I need to correct mysef, a litte bit, this doesn't seem to be a bug, but a feature.\n> There are 2 things to be noticed:\n> - The xml file has been commited with CRLF\n> - git am strips the CR (because they -may- have been added by a mail program)\n>\n> There are 2 different solutions:\n> a) Use git am --keep-cr\n> b) \"Normalize\" the xml file(s), and commit them to have LF in the repo,\n>      they can still have CRLF in the work tree, if needed.\n>      This is done by\n>      echo \"*.xml text\" >>.gitattributes\n>      touch *.xml\n>      git add *.xml .gitattributes\n>      git commit -m \"Normalize xml files\"\n>\n>\n> If you really need the xml files with CRLF, use this line instead:\n>      echo \"*.xml eol=CRLF\" >>.gitattributes\n>\n> HTH\n> /Torsten\n\nThank you.\n\nI will use a) the solution, because I use git am to apply custom patches \nto the Android tree from vendorsetup.sh in my device tree at \". \nbuild/envsetup.sh\" execution and just want git to apply commits what I \ndid earlier, when the upstream repositories changes (instead of forking \nthe upstream repositories, and then merge the upstream changes to the \nend of the world).\n\nThanks for your answer, it's really useful. Good luck in patching your \nissue!\n\n"}]}