Game Development Community

Are diff (patch files) cross platform??

by John Kabus (BobTheCBuilder) · in Technical Issues · 08/08/2004 (4:46 pm) · 5 replies

I've been spending a ridiculous amount of time trying to build patch files that work cross platform. I was under the impression that not only is it possible, but that it's easy. Unfortunately I haven't had any success.

I started out building patch files with GNU utils for Win32 using:

diff -rdu "" "" > filename.patch

Which works fine with the patch provided in GNU-Win32, but fails miserably on Linux and Mac ("Hunk #n FAILED at line x.").

Then I tried using cvs to build the patch files, referring to the Torque docs for help, but the process generated files identical the to diff files, which of course still didn't work.

Finally I tried building the patch files on Mac the files work great on Mac, but crash GNU-Win32's patch and error out Cygwin's patch ("Hunk #n FAILED at line x.").

What's going on?? Any ideas?

Thanks!

-John

#1
08/08/2004 (4:54 pm)
...
#2
08/09/2004 (5:05 am)
Hi Joseph,

Good call I tried running both diff and patch with the '--binary' argument and was able to get consistent results between Cygwin and GNU-Win32. I still need to test the files cross-platform, but things are looking better.

To give you an idea of the crazy results I was getting between Cygwin and GNU-Win32 try this in Cygwin:

-create a text file named 'test.txt' and add random text to it.
-copy the text file to 'test2.txt' and alter it.
-run the following command in Cygwin:

/bin/diff -rdu test.txt test2.txt | /bin/patch -p0 --verbose

Hmmm... doesn't work. Run it again and it will, apparently the first time it altered the target file and removed the carriage returns.

Anyway it works consistently on all windows versions of diff and patch using:

/bin/diff rdu --binary test.txt test2.txt | /bin/patch -p0 --verbose --binary

I'll run cross-platform tests tonight.

Thanks!

-John
#3
08/31/2004 (7:43 am)
Hey Bob, I'm trying to make a patch myself. Please don't forget to post your successful results tonight if you can :)
#4
09/01/2004 (4:53 am)
Hi Bryan,

My last post shows the solution - it's:

diff rdu --binary >

To build the patch and:

patch -p0 --binary <

To apply it.

I recommend using Cygwin's diff.

Hope this helps!

-John
#5
09/03/2004 (10:12 am)
Cool! Works great! Thanks John :)