Whole document tree
9. Handling binary filesThe most common use for CVS is to store text files. With text files, CVS can merge revisions, display the differences between revisions in a human-visible fashion, and other such operations. However, if you are willing to give up a few of these abilities, CVS can store binary files. For example, one might store a web site in CVS including both text files and binary images.
9.1 The issues with binary filesWhile the need to manage binary files may seem obvious if the files that you customarily work with are binary, putting them into version control does present some additional issues.
One basic function of version control is to show the
differences between two revisions. For example, if
someone else checked in a new version of a file, you
may wish to look at what they changed and determine
whether their changes are good. For text files,
CVS provides this functionality via the Another ability of a version control system is the ability to merge two revisions. For CVS this happens in two contexts. The first is when users make changes in separate working directories (see section 10. Multiple developers). The second is when one merges explicitly with the `update -j' command (see section 5. Branching and merging). In the case of text files, CVS can merge changes made independently, and signal a conflict if the changes conflict. With binary files, the best that CVS can do is present the two different copies of the file, and leave it to the user to resolve the conflict. The user may choose one copy or the other, or may run an external merge tool which knows about that particular file format, if one exists. Note that having the user merge relies primarily on the user to not accidentally omit some changes, and thus is potentially error prone. If this process is thought to be undesirable, the best choice may be to avoid merging. To avoid the merges that result from separate working directories, see the discussion of reserved checkouts (file locking) in 10. Multiple developers. To avoid the merges resulting from branches, restrict use of branches.
9.2 How to store binary filesThere are two issues with using CVS to store binary files. The first is that CVS by default converts line endings between the canonical form in which they are stored in the repository (linefeed only), and the form appropriate to the operating system in use on the client (for example, carriage return followed by line feed for Windows NT). The second is that a binary file might happen to contain data which looks like a keyword (see section 12. Keyword substitution), so keyword expansion must be turned off. The `-kb' option available with some CVS commands insures that neither line ending conversion nor keyword expansion will be done. Here is an example of how you can create a new file using the `-kb' flag:
If a file accidentally gets added without `-kb',
one can use the
When you check in the file `kotest' the file is
not preserved as a binary file, because you did not
check it in as a binary file. The
However, in using
You can also set a default for whether
This document was generated on September, 1 2005 using texi2html |