Making patches: the diff program

javelin's picture

The "diff" program (a standard unix utility) can produce apatchfile, given the original and revised source code
files. For example, if you revise player.c, and save the older version as player.c.orig, you could make a patchfile like this:

    diff -c player.c.orig player.c > patchfile

The "-c" switch indicates that you want a context diff, which is more detailed than an ordinary diff and better for patches. If you're going to publicly distribute the patch, be sure it's a context diff! (Another diff format, unified diff, is also appropriate. You can use "-u" to get a unified diff. Some people find them easier to read, and some -- like me -- don't.)

The order of the files is important. The patchfile will be written to apply the differences between player.c.orig and player.c so that player.c will be the end result.

If there's more than one source file changed, you can do this:

    diff -c player.c.orig player.c > patchfile
    diff -c game.c.orig game.c >> patchfile

You may be able to quickly make a collection of
diffs across the whole PennMUSH source tree by using David
Cheatham's mkpatch shell script, which is
available at http://ftp.pennmush.org/Accessories/mkpatch