Synopsis: diff [OPTIONS] [FILES]
- Alternate names – di, dif
- Requires – Working copy, repository
- Changes – Nothing
Shows the difference between two revisions (in Unix diff format). When
invoked with no options, CVS diffs the repository base revisions against
the (possibly uncommitted) contents of the working copy. The base
revisions are the latest revisions of this working copy retrieved from
the repository; note that there could be even later revisions in the
repository, if someone else committed changes but this working copy
hasn't been updated yet. (See also rdiff.)
- -D DATE – Diffs against the latest revisions no later than DATE.
Behaves like -r REV, except uses dates rather than revisions. (See -r
- -k MODE – Expands RCS keywords in the diffs according to MODE. (See
the section Keyword Substitution (RCS Keywords) in this chapter
for possible modes.)
- -l – Local. If no files were specified as arguments, this option diffs
files in the current directory, but does not descend into
- -R – Recursive. This option is the opposite of -l. This is the
default behavior, so the only reason to specify -R is to counteract a -l
in a .cvsrc file.
- -r REV or -r REV1 -r REV2 – Diffs against (or between) the specified
revisions. With one -r option, this diffs revision REV against your
working copy of that file (so when multiple files are being diffed, REV
is almost always a tag). With two -r options, it diffs REV1 against
REV2 for each file (and the working copy is, therefore, irrelevant).
The two revisions can be in any order – REV1 does not have to be an
earlier revision than REV2. The output reflects the direction of
change. With no -r options, it shows the difference between the working
file and the revision on which it is based.
Diff Compatibility Options
In addition to the preceding options, cvs diff also shares a number of
options with the GNU version of the standard command-line diff program.
Following is a complete list of these options, along with an explanation
of a few of the most commonly used ones. (See the GNU diff documentation
for the others.)
-0 -1 -2 -3 -4 -5 -6 -7 -8 -9
Following are the GNU diff options most frequently used with cvs diff.
- -B – Ignores differences that are merely the insertion or deletion of
blank lines (lines containing nothing but whitespace characters).
- -b – Ignores differences in the amount of whitespace. This option
treats all whitespace sequences as being equal and ignores whitespace at
line end. More technically, this option collapses each whitespace
sequence in the input to a single space and removes any trailing
whitespace from each line, before taking the diff. (See also -w.)
- -c – Shows output in context diff format, defaulting to three lines of
context per difference (for the sake of the patch program, which
requires at least two lines of context).
- -C NUM – context=NUM – Like -c, but with NUM lines of context.
- -i – Compares case insensitively. Treats upper- and lowercase versions
of a letter as the same.
- -u – Shows output in unified diff format.
- -w – Ignores all whitespace differences, even when one side of the
input has whitespace where the other has none. Essentially a stronger
version of -b.