git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* How to prepare patch for git am which remove a file ?
@ 2018-11-20 12:39 Mathieu Malaterre
  2018-11-20 12:55 ` SZEDER Gábor
  0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Malaterre @ 2018-11-20 12:39 UTC (permalink / raw)
  To: git

Here is a simple setup:

  cd /tmp
  mkdir g
  cd g
  git init .
  wget http://central.maven.org/maven2/org/apache/xmlgraphics/fop/2.1/fop-2.1.pom
  git add fop-2.1.pom
  git commit -m "My First Commit"
  git rm fop-2.1.pom
  git commit -m "Second Commit"
  git format-patch HEAD~
  git reset --hard HEAD~
  git am 0001-Second-Commit.patch
Applying: Second Commit
error: patch failed: fop-2.1.pom:1
error: fop-2.1.pom: patch does not apply
Patch failed at 0001 Second Commit
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

What is the black magic to get `git am` to understand this patch ?
Please note that:

$ patch --dry-run -p1 < 0001-Second-Commit.patch
checking file fop-2.1.pom

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to prepare patch for git am which remove a file ?
  2018-11-20 12:39 How to prepare patch for git am which remove a file ? Mathieu Malaterre
@ 2018-11-20 12:55 ` SZEDER Gábor
  2018-11-20 13:08   ` Mathieu Malaterre
  0 siblings, 1 reply; 3+ messages in thread
From: SZEDER Gábor @ 2018-11-20 12:55 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: git

On Tue, Nov 20, 2018 at 01:39:40PM +0100, Mathieu Malaterre wrote:
> Here is a simple setup:
> 
>   cd /tmp
>   mkdir g
>   cd g
>   git init .
>   wget http://central.maven.org/maven2/org/apache/xmlgraphics/fop/2.1/fop-2.1.pom
>   git add fop-2.1.pom
>   git commit -m "My First Commit"
>   git rm fop-2.1.pom
>   git commit -m "Second Commit"
>   git format-patch HEAD~
>   git reset --hard HEAD~
>   git am 0001-Second-Commit.patch
> Applying: Second Commit
> error: patch failed: fop-2.1.pom:1
> error: fop-2.1.pom: patch does not apply
> Patch failed at 0001 Second Commit
> hint: Use 'git am --show-current-patch' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
> 
> What is the black magic to get `git am` to understand this patch ?

The file in question uses CRLF line endings.

  $ git am --keep-cr 0001-Second-Commit.patch
  Applying: Second Commit

For explanation I quote ad2c928001 (git-am: Add command line parameter
`--keep-cr` passing it to git-mailsplit, 2010-02-27):

  c2ca1d7 (Allow mailsplit (and hence git-am) to handle mails with CRLF
  line-endings, 2009-08-04) fixed "git mailsplit" to help people with
  MUA whose output from save-as command uses CRLF as line terminators by
  stripping CR at the end of lines.
  
  However, when you know you are feeding output from "git format-patch"
  directly to "git am", and especially when your contents have CR at the
  end of line, such stripping is undesirable.  To help such a use case,
  teach --keep-cr option to "git am" and pass that to "git mailinfo".


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to prepare patch for git am which remove a file ?
  2018-11-20 12:55 ` SZEDER Gábor
@ 2018-11-20 13:08   ` Mathieu Malaterre
  0 siblings, 0 replies; 3+ messages in thread
From: Mathieu Malaterre @ 2018-11-20 13:08 UTC (permalink / raw)
  To: szeder.dev; +Cc: git

On Tue, Nov 20, 2018 at 1:55 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
>
> On Tue, Nov 20, 2018 at 01:39:40PM +0100, Mathieu Malaterre wrote:
> > Here is a simple setup:
> >
> >   cd /tmp
> >   mkdir g
> >   cd g
> >   git init .
> >   wget http://central.maven.org/maven2/org/apache/xmlgraphics/fop/2.1/fop-2.1.pom
> >   git add fop-2.1.pom
> >   git commit -m "My First Commit"
> >   git rm fop-2.1.pom
> >   git commit -m "Second Commit"
> >   git format-patch HEAD~
> >   git reset --hard HEAD~
> >   git am 0001-Second-Commit.patch
> > Applying: Second Commit
> > error: patch failed: fop-2.1.pom:1
> > error: fop-2.1.pom: patch does not apply
> > Patch failed at 0001 Second Commit
> > hint: Use 'git am --show-current-patch' to see the failed patch
> > When you have resolved this problem, run "git am --continue".
> > If you prefer to skip this patch, run "git am --skip" instead.
> > To restore the original branch and stop patching, run "git am --abort".
> >
> > What is the black magic to get `git am` to understand this patch ?
>
> The file in question uses CRLF line endings.

Ah right, I wasn't paying attention. Thanks.

>   $ git am --keep-cr 0001-Second-Commit.patch
>   Applying: Second Commit
>
> For explanation I quote ad2c928001 (git-am: Add command line parameter
> `--keep-cr` passing it to git-mailsplit, 2010-02-27):
>
>   c2ca1d7 (Allow mailsplit (and hence git-am) to handle mails with CRLF
>   line-endings, 2009-08-04) fixed "git mailsplit" to help people with
>   MUA whose output from save-as command uses CRLF as line terminators by
>   stripping CR at the end of lines.
>
>   However, when you know you are feeding output from "git format-patch"
>   directly to "git am", and especially when your contents have CR at the
>   end of line, such stripping is undesirable.  To help such a use case,
>   teach --keep-cr option to "git am" and pass that to "git mailinfo".
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-20 13:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-20 12:39 How to prepare patch for git am which remove a file ? Mathieu Malaterre
2018-11-20 12:55 ` SZEDER Gábor
2018-11-20 13:08   ` Mathieu Malaterre

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).