git diff sees whole file as changed when it's not [duplicate]

The git diff engine is seeing a whole file as changed when it has not. For example, take this commit: https://github.com/etiago/phpvirtualbox/commit/626e09958384f479f94011ac3b8301bd497aec51

Here we see that the file lib/vboxconnector.php has 2807 additions and 2778 deletions. Additionally, from doing a manual git diff I find that indeed, the whole file is taken in as a deletion (marked with minus) and a whole new file is taken as an addition. However, the files have a lot in common which Git simply ignored.

I've looked at diff returning entire file for identical files but it does not seem to be the case as no white space changes exist between the two commits.

Furthermore, taking the two commits of the file (the one in 626e09958384f479f94011ac3b8301bd497aec51 and 626e09958384f479f94011ac3b8301bd497aec51^1) and diff'ing them using Meld, I get the right diff analysis.

I've uploaded the two commits of the file to my Dropbox for convenience: commit_1 commit_2.


In vboxconnector.php_1, every line is terminated by a CR LF sequence.

In vboxconnector.php_2, every line is terminated by just LF.

Thus every line of the file has changed.

Try using git diff --ignore-space-at-eol.

You may also find some useful information in the answers to this question.