diff tool is used to create patches (sometimes called
diffs). A patch is a program (computer science definition) which
modifies text across one or more files. Typically these are used for
making changes to source code before it is compiled.
The simplest invocation is
diff -u oldfile newfile, which will
create a list of differences in unified format between
newfile. To operate over directories instead, use
-urN olddir newdir.
cvsprovide built-in diff functionality (
cvs diff) which may be more helpful.
For patches which go in the main tree, use unified (
format. This is generally the best format to use when sending patches
upstream too — however, occasionally you may be asked to provide
context diffs, which are more portable than unifieds (but don't handle
conflicts as cleanly). In this case, use
-u. For a verbose guide into patches and patching, see
To apply a patch, use
patch -pX < whatever.patch,
X is a number representing the number of path components
which must be removed (typically this is
ebuilds, use the
epatch function, or
beginning with EAPI=6, instead — see
Patching with epatch and eapply.
patch(1) manual pages provide more information.