Info for the item "does patch.exe work different than other unx patch tools?" (i.e. "hunk 1 out of 3 hunks failed")
Thu Nov 8 10:30:00 GMT 2012
using Cygwin patch.exe in a batch file I ran into the problem that
patch failed for some reason ("hunk 1 out of 3 hunks failed"):
Investigating this issue I found that inserting "unix2dos my.patch"
before applying the patch was my friend!
Being paranoid I tried "dos2unix my.patch" before applying the patch
- and it was my friend too!
Than I tried to run my batch script again without any unix2dos or
dos2unix commands and I had my problem back. I have to say here, that
my.patch is generated using diff inside my batch.
So now I had a closer look to the diff generated my.patch file and I
found out, that the file had somehow hybrid line endings:
* the header with the file names was unix-like
* the body with the diff info was dos-like
The reason probably is, that my sources are with dos-like line
endings. I assume, diff starts creating the my.patch with unix-like
line-endings and than adds the diff info as it is.
Than, when patch.exe gets the my.patch to execute it it sees unix-like
line endings at the beginning of the my.patch, assumes all is that way
and gets later trouble applying the patch info.
I do not regard this as a bug, but I guess I am not the only one
spending a few hours with that issue.
I would like to propose an additional command line switch for the
Cygwin diff.exe and/or patch.exe to tell about the line-endings.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin