tags:

views:

640

answers:

3

When git does a commit it rewrites binary files with something similar to "rewrite foobar.bin (76%)" . What is that %? Is it percent changed or percent retained from the older file. I know that git uses a binary delta for files, but I just don't know how much of a rewrite the % represents and it doesn't seem to be in the help page for "git help commit" .

Thanks!

A: 

It is attempting to rewrite CRs and LFs into a consistent format. That is, it doesn't see your binary file as binary. To force git to do this properly put the following line in .gitattributes:

*.bin -crlf -diff -merge

From this page that means:

all files with a [.bin] extension will not have carriage return/line feed translations done, won't be diffed and merges will result in conflicts leaving the original file untouched.

Talljoe
This is not what "rewrite" means in the context of the question. Git is saying "hey it looks like you rewrote this file but left 76% of it the same as it was before".
Greg Hewgill
+2  A: 

Its a measure of the similarity index. The similarity index is the percentage of unchanged lines. git thinks your file is text.

Martin Redmond
I believe the similarity index is unrelated to whether Git thinks the file is text. Not certain on that, as some binary files can look a lot like text.
Greg Hewgill
+1  A: 

I believe Martin is correct, that number is the similarity index. From the git-diff man pages:

The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It is a rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one.

First time I saw the number I thought my binaries were changing dramatically!.

Daniel Gill