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.
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.

Reply via email to