Hi,

How can we...

1. use the Ant task |patch| in Linux for patching files with DOS linefeeds?
2. apply the option |--binary| with the Ant task |patch|?

See the details below or at Stack Overflow <https://stackoverflow.com/q/63703418/2158271>.

Kind regards,

Harri


   Files

 * build.xml
   <https://github.com/haba713/ant_patch_crlf/blob/master/build.xml>:
   Ant build file with a patch task
 * test.patch
   <https://github.com/haba713/ant_patch_crlf/blob/master/test.patch>:
   patch file with DOS linefeeds
 * test.txt
   <https://github.com/haba713/ant_patch_crlf/blob/master/test.txt>:
   source file with DOS linefeeds


   Command line |patch| fails

DOS linefeeds in the patch file are converted into Unix linefeeds and patching fails:

|[0] mypc<u0>:~/src/test/ant_patch_crlf>patch -i test.patch (Stripping trailing CRs from patch; use --binary to disable.) patching file test.txt Hunk #1 FAILED at 1 (different line endings). 1 out of 1 hunk FAILED -- saving rejects to file test.txt.rej|


   Command line |patch --binary| works fine

As suggested above

   |use --binary to disable|

adding the option |--binary| helps:

|[0] mypc<u0>:~/src/test/ant_patch_crlf>patch --binary -i test.patch patching file test.txt|


   Ant task |patch| fails

Ant task |patch| fails with the same error than command line without the option |--binary|:

|[0] mypc<u0>:~/src/test/ant_patch_crlf>ant Buildfile: /home/u0/src/test/ant_patch_crlf/build.xml patch: [patch] (Stripping trailing CRs from patch; use --binary to disable.) [patch] patching file test.txt [patch] Hunk #1 FAILED at 1 (different line endings). [patch] 1 out of 1 hunk FAILED -- saving rejects to file test.txt.rej [patch] 'patch' failed with exit code 1 BUILD SUCCESSFUL Total time: 0 seconds|


Reply via email to