GNU Info

Info Node: (cvsbook.info)CVS And Binary Files

(cvsbook.info)CVS And Binary Files


Next: Removing Files Prev: Adding Directories Up: Other Useful CVS Commands
Enter node , (file) or (file)node

CVS And Binary Files
--------------------

Until now, I've left unsaid the dirty little secret of CVS, which is
that it doesn't handle binary files very well (well, there are other
dirty little secrets, but this definitely counts as one of the
dirtiest).  It's not that CVS doesn't handle binaries at all; it does,
just not with any great panache.

All the files we've been working with until now have been plain text
files.  CVS has some special tricks for text files.  For example, when
it's working between a Unix repository and a Windows or Macintosh
working copy, it converts file line endings appropriately for each
platform.  For example, Unix convention is to use a linefeed (LF) only,
whereas Windows expects a carriage return/linefeed (CRLF) sequence at
the end of each line.  Thus, the files in a working copy on a Windows
machine will have CRLF endings, but a working copy of the same project
on a Unix machine will have LF endings (the repository itself is always
stored in LF format).

Another trick is that CVS detects special strings, known as RCS keyword
strings, in text files and replaces them with revision information and
other useful things.  For example, if your file contains this string

     $Revision$

CVS will expand on each commit to include the revision number.  For
example, it may get expanded to

     $Revision: 1.3 $

CVS will keep that string up to date as the file is developed.  (The
various keyword strings are documented in Note: Advanced CVS and
Note: Third-Party Tools.)

This string expansion is a very useful feature in text files, as it
allows you to see the revision number or other information about a file
while you're editing it.  But what if the file is a JPG image?  Or a
compiled executable program?  In those kinds of files, CVS could do some
serious damage if it blundered around expanding any keyword string that
it encountered.  In a binary, such strings may even appear by
coincidence.

Therefore, when you add a binary file, you have to tell CVS to turn off
both keyword expansion and line-ending conversion.  To do so, use -kb:

     floss$ cvs add -kb filename
     floss$ cvs ci -m "added blah" filename
       (etc)

Also, in some cases (such as text files that are likely to contain
spurious keyword strings), you may wish to disable just the keyword
expansion.  That's done with -ko:

     floss$ cvs add -ko filename
     floss$ cvs ci -m "added blah" filename
       (etc)

(In fact, this chapter is one such document, because of the
`$Revision$' example shown here.)

Note that you can't meaningfully run `cvs diff' on two revisions of a
binary file.  Diff uses a text-based algorithm that can only report
whether two binary files differ, but not how they differ.  Future
versions of CVS may provide a way to diff binary files.


automatically generated by info2www version 1.2.2.9