You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Harri T." <ha...@gmail.com> on 2020/09/02 11:03:51 UTC

Can the Ant task "patch" be used in Linux for patching files with DOS linefeeds?

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|



Re: Can the Ant task "patch" be used in Linux for patching files with DOS linefeeds?

Posted by Stefan Bodewig <bo...@apache.org>.
On 2020-09-02, Harri T. wrote:

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

Th patch task doesn't support --binary, yet, but it would be very easy
to add.

Actually <patch> is really a simple wrapper for <exec>, the easiest
approach probably is to use <exec> instead of the task.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org