Default options and the ~/.cvsrc and CVSROOT/cvsrc files

There are some command_options that are used so often that you might have set up an alias or some other means to make sure you always specify that option. One example (the one that drove the implementation of the .cvsrc support, actually) is that many people find the default output of the diff command to be very hard to read, and that either context diffs or unidiffs are much easier to understand.

The ~/.cvsrc file is a way that you can add default options to cvs_commands within cvs, instead of relying on aliases or other shell scripts.

The format of the ~/.cvsrc file is simple. The file is searched for a line that begins with the same name as the cvs_command being executed. If a match is found, then the remainder of the line is split up (at whitespace characters) into separate options and added to the command arguments before any options from the command line.

If a command has two names (e.g., checkout and co), the official name, not necessarily the one used on the command line, will be used to match against the file. So if this is the contents of the user's ~/.cvsrc file:

log -N
diff -u
update -P
checkout -P

the command cvs checkout foo would have the -P option added to the arguments, as well as cvs co foo.

With the example file above, the output from cvs diff foobar will be in unidiff format. cvs diff -c foobar will provide context diffs, as usual. Getting "old" format diffs would be slightly more complicated, because diff doesn't have an option to specify use of the "old" format, so you would need cvs -f diff foobar.

In place of the command name you can use cvsnt to specify global options (the section called “Global options”). For example the following line in .cvsrc

cvs -z6

causes cvsnt to use compression level 6.

The CVSROOT/cvsrc file on the server contains the default .cvsrc file that is used by all compatible clients. This is merged with the local .cvsrc file and the result behaves as normal.

The CVSROOT/cvsrc file cannot contain global options (the section called “Global options”) as it is parsed after the server has started.

Older cvsnt clients and Unix cvs clients will not use the global cvsrc.