{"thread":{"id":"49866","subject":"How to prepare patch for git am which remove a file ?","startedAt":"2018-11-20T12:39:55Z","lastAt":"2018-11-20T13:08:33Z","messageCount":3,"participants":["Mathieu Malaterre","SZEDER Gábor"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"363733","messageId":"CA+7wUsz5WyRcxMTUWTg13K866vWWp+bVGSZJFU1hRSL1Ehr8Aw@mail.gmail.com","threadId":"49866","inReplyTo":null,"subject":"How to prepare patch for git am which remove a file ?","fromName":"Mathieu Malaterre","fromEmail":"malat@debian.org","sentAt":"2018-11-20T12:39:40Z","receivedAt":"2018-11-20T12:39:55Z","isPatch":false,"sender":{"key":"malat@debian.org","avatar":null},"body":"Here is a simple setup:\n\n  cd /tmp\n  mkdir g\n  cd g\n  git init .\n  wget http://central.maven.org/maven2/org/apache/xmlgraphics/fop/2.1/fop-2.1.pom\n  git add fop-2.1.pom\n  git commit -m \"My First Commit\"\n  git rm fop-2.1.pom\n  git commit -m \"Second Commit\"\n  git format-patch HEAD~\n  git reset --hard HEAD~\n  git am 0001-Second-Commit.patch\nApplying: Second Commit\nerror: patch failed: fop-2.1.pom:1\nerror: fop-2.1.pom: patch does not apply\nPatch failed at 0001 Second Commit\nhint: Use 'git am --show-current-patch' to see the failed 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\nWhat is the black magic to get `git am` to understand this patch ?\nPlease note that:\n\n$ patch --dry-run -p1 < 0001-Second-Commit.patch\nchecking file fop-2.1.pom\n\nThanks!\n"},{"id":"363736","messageId":"20181120125520.GZ30222@szeder.dev","threadId":"49866","inReplyTo":"CA+7wUsz5WyRcxMTUWTg13K866vWWp+bVGSZJFU1hRSL1Ehr8Aw@mail.gmail.com","subject":"Re: How to prepare patch for git am which remove a file ?","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2018-11-20T12:55:20Z","receivedAt":"2018-11-20T12:55:26Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, Nov 20, 2018 at 01:39:40PM +0100, Mathieu Malaterre wrote:\n> Here is a simple setup:\n> \n>   cd /tmp\n>   mkdir g\n>   cd g\n>   git init .\n>   wget http://central.maven.org/maven2/org/apache/xmlgraphics/fop/2.1/fop-2.1.pom\n>   git add fop-2.1.pom\n>   git commit -m \"My First Commit\"\n>   git rm fop-2.1.pom\n>   git commit -m \"Second Commit\"\n>   git format-patch HEAD~\n>   git reset --hard HEAD~\n>   git am 0001-Second-Commit.patch\n> Applying: Second Commit\n> error: patch failed: fop-2.1.pom:1\n> error: fop-2.1.pom: patch does not apply\n> Patch failed at 0001 Second Commit\n> hint: Use 'git am --show-current-patch' to see the failed patch\n> When you have resolved this problem, run \"git am --continue\".\n> If you prefer to skip this patch, run \"git am --skip\" instead.\n> To restore the original branch and stop patching, run \"git am --abort\".\n> \n> What is the black magic to get `git am` to understand this patch ?\n\nThe file in question uses CRLF line endings.\n\n  $ git am --keep-cr 0001-Second-Commit.patch\n  Applying: Second Commit\n\nFor explanation I quote ad2c928001 (git-am: Add command line parameter\n`--keep-cr` passing it to git-mailsplit, 2010-02-27):\n\n  c2ca1d7 (Allow mailsplit (and hence git-am) to handle mails with CRLF\n  line-endings, 2009-08-04) fixed \"git mailsplit\" to help people with\n  MUA whose output from save-as command uses CRLF as line terminators by\n  stripping CR at the end of lines.\n  \n  However, when you know you are feeding output from \"git format-patch\"\n  directly to \"git am\", and especially when your contents have CR at the\n  end of line, such stripping is undesirable.  To help such a use case,\n  teach --keep-cr option to \"git am\" and pass that to \"git mailinfo\".\n\n"},{"id":"363741","messageId":"CA+7wUsxGdrYKsoydBk0iwmANM=4qxVJ7NoVv6=E_UPH6FuiaaA@mail.gmail.com","threadId":"49866","inReplyTo":"20181120125520.GZ30222@szeder.dev","subject":"Re: How to prepare patch for git am which remove a file ?","fromName":"Mathieu Malaterre","fromEmail":"malat@debian.org","sentAt":"2018-11-20T13:08:17Z","receivedAt":"2018-11-20T13:08:33Z","isPatch":false,"sender":{"key":"malat@debian.org","avatar":null},"body":"On Tue, Nov 20, 2018 at 1:55 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:\n>\n> On Tue, Nov 20, 2018 at 01:39:40PM +0100, Mathieu Malaterre wrote:\n> > Here is a simple setup:\n> >\n> >   cd /tmp\n> >   mkdir g\n> >   cd g\n> >   git init .\n> >   wget http://central.maven.org/maven2/org/apache/xmlgraphics/fop/2.1/fop-2.1.pom\n> >   git add fop-2.1.pom\n> >   git commit -m \"My First Commit\"\n> >   git rm fop-2.1.pom\n> >   git commit -m \"Second Commit\"\n> >   git format-patch HEAD~\n> >   git reset --hard HEAD~\n> >   git am 0001-Second-Commit.patch\n> > Applying: Second Commit\n> > error: patch failed: fop-2.1.pom:1\n> > error: fop-2.1.pom: patch does not apply\n> > Patch failed at 0001 Second Commit\n> > hint: Use 'git am --show-current-patch' to see the failed patch\n> > When you have resolved this problem, run \"git am --continue\".\n> > If you prefer to skip this patch, run \"git am --skip\" instead.\n> > To restore the original branch and stop patching, run \"git am --abort\".\n> >\n> > What is the black magic to get `git am` to understand this patch ?\n>\n> The file in question uses CRLF line endings.\n\nAh right, I wasn't paying attention. Thanks.\n\n>   $ git am --keep-cr 0001-Second-Commit.patch\n>   Applying: Second Commit\n>\n> For explanation I quote ad2c928001 (git-am: Add command line parameter\n> `--keep-cr` passing it to git-mailsplit, 2010-02-27):\n>\n>   c2ca1d7 (Allow mailsplit (and hence git-am) to handle mails with CRLF\n>   line-endings, 2009-08-04) fixed \"git mailsplit\" to help people with\n>   MUA whose output from save-as command uses CRLF as line terminators by\n>   stripping CR at the end of lines.\n>\n>   However, when you know you are feeding output from \"git format-patch\"\n>   directly to \"git am\", and especially when your contents have CR at the\n>   end of line, such stripping is undesirable.  To help such a use case,\n>   teach --keep-cr option to \"git am\" and pass that to \"git mailinfo\".\n>\n"}]}