After you obtained the source code, made changes to it, built and tested it, you might want to get your changes reviewed and checked in. In order to do that, you need to create a file listing the changes you made, called a patch or a diff file. You can generate it using cvs diff command.
Creating a diff of a single file
In order to create a diff of a single local file against the current file in the repository, use:
$ cvs diff -u8p FILENAME
This creates a diff in the so called 'unified' format (<tt>-u</tt>), with 8 lines of context. The diff is printed to stdout by default. To redirect the output to a file, use something like:
$ cvs diff -u8p FILENAME > OUT_FILE
Creating a diff for multiple files
If, instead of using a regular file for FILENAME, you provide a directory, then this directory as well as all subdirectories will be searched recursively. For example
$ cvs diff -u8p . > OUT_FILE
will compare all files in the current directory and all its subdirectories against the versions in the repository, and write the combined unified diffs to a file named OUT_FILE, using 8 lines of context.
There should be enough context in the patch for it to be understood without opening the source file. The default guideline is to use 8 lines of context; if more context is required to make the patch understandable, replace 8 with a higher number. Also note that the more context you include, the greater the chance to be able to also apply the patch to a file which differs heavily from the original source against which the diff was prepared.
Including new files in a patch
To include a new file in your patch, use the <tt>-N</tt> option:
$ cvs diff -u8pN . > OUT_FILE
A common problem here is that cvs diff will not include the new files that were not cvs added, and cvs add requires write access to repository.
The solution is to use cvsdo utility , which edits <tt>CVS/Entries</tt> to make cvs think the file is added to repository:
$ cvsdo add NEWFILE $ cvs diff -u8pN NEWFILE > OUT_FILE