Alex Rivera | Logout

How to apply diff made by windows SVN on linux?

Asked 2010-07-02T08:07:16.967
9

On windows i created a multi-file diff with:

svn diff > mydiff.diff

Then moved it to linux machine (with the same version of the same repo, no changes). How cai i apply it? After executing

 patch -p0 < mydiff.diff

I get the following output:

patching file licstat/test/unittest/test_licstatactioncontainers.cpp
File licstat/test/unittest/test_licstatactioncontainers.cpp is not empty after patch, as expected
patching file licstat/test/unittest/test_licstatactions.cpp
Hunk #1 FAILED at 99.
1 out of 1 hunk FAILED -- saving rejects to file licstat/test/unittest/test_licstatactions.cpp.rej
can't find file to patch at input line 295
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: licstat/test/unittest/test_licenseserverusagemap.cpp
|===================================================================
|--- licstat/test/unittest/test_licenseserverusagemap.cpp       (revision 6767)
|+++ licstat/test/unittest/test_licenseserverusagemap.cpp       (working copy)
--------------------------
File to patch: 

And the last line is prompt waiting for my action.

How should I create/apply the patch to make it work?

(edit) Now I see, that the file was missing and diff didn't create it. After creating the file manually I get errors like this:

patching file licstat/misc/generic/mysql/stored_procedures.sql
Hunk #1 FAILED at 220.
Hunk #2 FAILED at 245.
Hunk #3 FAILED at 622.
Hunk #4 FAILED at 661.
Hunk #5 FAILED at 810.
Hunk #6 FAILED at 822.
Hunk #7 FAILED at 868.
Hunk #8 FAILED at 999.
8 out of 8 hunks FAILED -- saving rejects to file licstat/misc/generic/mysql/stored_procedures.sql.rej
Edit
Report

2 Answers

8

Using "dos2unix" will not help if you have CR+LF line feed in your files on Linux.

This command should do the job with any combination of line feeds:

patch -p0 -l --binary < patch.diff
answered 2012-06-04T09:03:35.997
0

That type of error can occur when the local file format is CRLF instead of LF when you're on a unix system.

patch tries to adapt the svn diff patch to the unix file format but trips up when the local files are in dos mode, which can happen when you share code bases between dos and unix environments.

What works for me is to first convert all the files about to be affected, for example:

grep ^+++ patchfile.patch | awk '{print $2}' | dos2unix

And then to apply the patch:

patch -p0 < patchfile.patch
answered 2010-07-02T08:09:22.437

Your Answer