Monday, August 08, 2005

diff/patch

copied from http://kegel.com/academy/opensource.html

Making Patches

To create a patch, you run a program called diff, and save its output to a file. For instance, if the original source tree is in directory "foobar.old", and your new sources are in directory "foobar.new", the command
diff -Naur foobar.old foobar.new > blarg.patch
will create the file 'blarg.patch' containing your changes in 'unified context diff' format.

Using Patches

To use a patch -- that is, to automatically carry out the changes described in a patch file -- you run a program called patch. For instance, if you're trying to apply the patch 'blarg.patch' to a package called foobar-0.17, you might say
cd foobar-0.17; patch -p1 < ../blarg.patch
That would merge the changes from blarg.patch into your source tree. (The -p1 tells patch to ignore the first directory in filenames in the patch; that way a patch generated against the directory foobar-0.11 will still apply properly.)

No comments: