Binary blobs

Git and CVS handle binary files differently. In CVS, it is harder to handle them since you have to explicitly label them as binary. If you don't, you run the risk of corrupting the file with unwanted LR/LF conversions or keyword substitutions. Git, on the other hand, can automatically detect whether your file is of the binary kind. It uses the same mechanism as GNU diffutils.

Let's create a simple binary from source and add a reserved keyword. Then, we will compile it with GCC and run it:

$ cat hello.c
#include <stdio.h>
int main()
{
// printf() displays the string inside quotation
printf("Hello, World!$Author$");
return 0;
}

$ gcc hello.c -o hello

$ ./hello
Hello, World!$Author$

So, let's copy the binary to the CVS project that we used previously:

$ cp hello /Users/joostevertse/cvs/cvsproject/cvsproject/
$ cd $HOME/cvs/cvsproject/cvsproject

$ cvs add hello
cvs add: scheduling file `hello' for addition
cvs add: use `cvs commit' to add this file permanently

$ cvs commit -m "binary with keywords inside"
cvs commit: Examining .
cvs commit: Examining images
/Users/joostevertse/cvsroot/cvsproject/cvsproject/hello,v <-- hello
initial revision: 1.1

$ ./hello
Segmentation fault: 11

What happened? Well, keyword substitution added the author name in the binary! It corrupted it. If you run the cat command, you will find the following line in the file:

1ɉE???H??]??%?L??AS?%q?h?????Hello, World!$Author: joostevertse $P44{4

Fortunately, you can fix this with cvs admin:

 $ cvs admin -kb hello
$ cvs update -A hello
$ cvs commit -m "make it binary" hello
$ ./hello
Hello, World!$Author$
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.104.120