git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] git am sometimes unable to apply git format-patch output file
@ 2017-08-12 16:02 Soul Trace
  2017-08-12 16:20 ` Torsten Bögershausen
  0 siblings, 1 reply; 4+ messages in thread
From: Soul Trace @ 2017-08-12 16:02 UTC (permalink / raw)
  To: git

Hello.

Using git i have found that git am command may sometimes fail to apply 
patch file which was created by the git am command.


Steps to reproduce:

# 1. Clone test repository:

git clone https://github.com/S-trace/git_am_bug_test.git

# 2. Format patch file for last commit:

git format-patch HEAD~

# 3. Go to previous commit:

git checkout HEAD~

# 4. Apply back patch file created in step 2:

git am 0001-UPDATE-Update-ascend_MOGOLIA_ULG_normal.xml.patch

The git am command fails on my machine with the following error message:

Applying: Update ascend_MOGOLIA_ULG_normal.xml
.git/rebase-apply/patch:6522: trailing whitespace.
     </scene>
error: patch failed: ascend_MOGOLIA_ULG_normal.xml:1
error: ascend_MOGOLIA_ULG_normal.xml: patch does not apply
Patch failed at 0001 Update ascend_MOGOLIA_ULG_normal.xml
The copy of the patch that failed is found in: .git/rebase-apply/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".


But patch command can handle this patch file:

patch -p1 -i 0001-UPDATE-Update-ascend_MOGOLIA_ULG_normal.xml.patch


Versions information:

git --version
git version 2.11.0

patch --version
GNU patch 2.7.5
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Larry Wall and Paul Eggert

uname -a
Linux omen 4.10.0-26-generic #30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017 
x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 17.04
Release:        17.04
Codename:       zesty


Thank you.


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

* Re: [BUG] git am sometimes unable to apply git format-patch output file
  2017-08-12 16:02 [BUG] git am sometimes unable to apply git format-patch output file Soul Trace
@ 2017-08-12 16:20 ` Torsten Bögershausen
  2017-08-12 17:01   ` Torsten Bögershausen
  0 siblings, 1 reply; 4+ messages in thread
From: Torsten Bögershausen @ 2017-08-12 16:20 UTC (permalink / raw)
  To: Soul Trace; +Cc: git

On Sat, Aug 12, 2017 at 07:02:59PM +0300, Soul Trace wrote:
> Hello.
> 
> Using git i have found that git am command may sometimes fail to apply patch
> file which was created by the git am command.
> 
> 
> Steps to reproduce:

Excellent, thanks so much for the detailed bug report.
This kind of information is really appreciated.

Why did I say excellent ?
Because I am working on a patch, which -should- fix exactly this kind of issues.
I send out a patch earlier this day, but it doesn't fix your issue, even if it should.
I hope to have a fix soonish.

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

* Re: [BUG] git am sometimes unable to apply git format-patch output file
  2017-08-12 16:20 ` Torsten Bögershausen
@ 2017-08-12 17:01   ` Torsten Bögershausen
  2017-08-16  7:45     ` Soul Trace
  0 siblings, 1 reply; 4+ messages in thread
From: Torsten Bögershausen @ 2017-08-12 17:01 UTC (permalink / raw)
  To: Soul Trace; +Cc: git

On Sat, Aug 12, 2017 at 06:20:23PM +0200, Torsten Bögershausen wrote:
> On Sat, Aug 12, 2017 at 07:02:59PM +0300, Soul Trace wrote:
> > Hello.
> > 
> > Using git i have found that git am command may sometimes fail to apply patch
> > file which was created by the git am command.
> > 
> > 
> > Steps to reproduce:
> 
> Excellent, thanks so much for the detailed bug report.
> This kind of information is really appreciated.
> 
> Why did I say excellent ?
> Because I am working on a patch, which -should- fix exactly this kind of issues.
> I send out a patch earlier this day, but it doesn't fix your issue, even if it should.
> I hope to have a fix soonish.

I need to correct mysef, a litte bit, this doesn't seem to be a bug, but a feature.
There are 2 things to be noticed:
- The xml file has been commited with CRLF
- git am strips the CR (because they -may- have been added by a mail program)

There are 2 different solutions:
a) Use git am --keep-cr
b) "Normalize" the xml file(s), and commit them to have LF in the repo,
    they can still have CRLF in the work tree, if needed.
    This is done by
    echo "*.xml text" >>.gitattributes
    touch *.xml
    git add *.xml .gitattributes
    git commit -m "Normalize xml files"


If you really need the xml files with CRLF, use this line instead:
    echo "*.xml eol=CRLF" >>.gitattributes

HTH
/Torsten

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

* Re: [BUG] git am sometimes unable to apply git format-patch output file
  2017-08-12 17:01   ` Torsten Bögershausen
@ 2017-08-16  7:45     ` Soul Trace
  0 siblings, 0 replies; 4+ messages in thread
From: Soul Trace @ 2017-08-16  7:45 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: git

12.08.2017 20:01, Torsten Bögershausen пишет:
> On Sat, Aug 12, 2017 at 06:20:23PM +0200, Torsten Bögershausen wrote:
>> On Sat, Aug 12, 2017 at 07:02:59PM +0300, Soul Trace wrote:
>>> Hello.
>>>
>>> Using git i have found that git am command may sometimes fail to apply patch
>>> file which was created by the git am command.
>>>
>>>
>>> Steps to reproduce:
>> Excellent, thanks so much for the detailed bug report.
>> This kind of information is really appreciated.
>>
>> Why did I say excellent ?
>> Because I am working on a patch, which -should- fix exactly this kind of issues.
>> I send out a patch earlier this day, but it doesn't fix your issue, even if it should.
>> I hope to have a fix soonish.
> I need to correct mysef, a litte bit, this doesn't seem to be a bug, but a feature.
> There are 2 things to be noticed:
> - The xml file has been commited with CRLF
> - git am strips the CR (because they -may- have been added by a mail program)
>
> There are 2 different solutions:
> a) Use git am --keep-cr
> b) "Normalize" the xml file(s), and commit them to have LF in the repo,
>      they can still have CRLF in the work tree, if needed.
>      This is done by
>      echo "*.xml text" >>.gitattributes
>      touch *.xml
>      git add *.xml .gitattributes
>      git commit -m "Normalize xml files"
>
>
> If you really need the xml files with CRLF, use this line instead:
>      echo "*.xml eol=CRLF" >>.gitattributes
>
> HTH
> /Torsten

Thank you.

I will use a) the solution, because I use git am to apply custom patches 
to the Android tree from vendorsetup.sh in my device tree at ". 
build/envsetup.sh" execution and just want git to apply commits what I 
did earlier, when the upstream repositories changes (instead of forking 
the upstream repositories, and then merge the upstream changes to the 
end of the world).

Thanks for your answer, it's really useful. Good luck in patching your 
issue!


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

end of thread, other threads:[~2017-08-16  7:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-12 16:02 [BUG] git am sometimes unable to apply git format-patch output file Soul Trace
2017-08-12 16:20 ` Torsten Bögershausen
2017-08-12 17:01   ` Torsten Bögershausen
2017-08-16  7:45     ` Soul Trace

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 NNTP newsgroup(s).