1

I've encountered a problem using the Git diff. For some reason, it seems to be misreading the files I change and the first letter of each line is put in the modified (+/-) line, like so:

This happens both on my app and my remote repo!

Class Php Comment

At first, I thought it was possibly an error with the file not being able to be read because of the ! defined ('BASEPATH') line, but this also occurs on files without this check, and also on my project's JS files. It reads perfectly on CSS, HTML and certain PHP files.

Perhaps I have something set up wrong, although this is the first repo I've had where I have ever had this problem. I don't know what information you'll need to know but if you require anything, please let me know and I will find out for you.

EDIT: The "FileMerge" tool shows the changes perfectly, if that helps.

FIX

This was, as KurzedMetal pointed out, a problem with Mac/Windows line endings. This is the fix I have used for the time being to convert the line endings for the time being. It's not perfect, and if someone can suggest a better (ideally, recursive) function I'd be happy to accept it.

perl -pi -w -e 's/\r\n|\n|\r/\n/g;' *.php

I've had to do this for each subdirectory, e.g.

perl -pi -w -e 's/\r\n|\n|\r/\n/g;' */*.php
nwellnhof
  • 32,319
  • 7
  • 89
  • 113
Joe McKie
  • 96
  • 1
  • 9
  • Where does that diff display come from? `git` itself is a text-based tool, so it's not a `git` issue specifically. You're using a GUI front-end. Is it directly from bitbucket? – lurker Aug 14 '13 at 18:50
  • Yes, just to clarify this can be replicated in both SourceTree and BitBucket. I will test it on GitHub and see what the results are there. – Joe McKie Aug 14 '13 at 18:53
  • You have a problem related with the file line endings (CRLF and LF). – KurzedMetal Aug 14 '13 at 19:21
  • @KurzedMetal - this is it, thanks! Half of our team works on Windows, and that was where the different line endings came in. What would you suggest to do to progress from here? – Joe McKie Aug 14 '13 at 20:03
  • You can set GIT to replace line endings on the windows machines, or make the windows users use sensible settings in their tools. – Steve Barnes Aug 14 '13 at 20:25
  • At the moment I'd be more concerned that none of the files work on Mac, I need to make them work for me first and then worry about everyone else. I'm trying [this fix](http://stackoverflow.com/questions/1510798/trying-to-fix-line-endings-with-git-filter-branch-but-having-no-luck/1511273#1511273), but it doesn't seem to be working for me. – Joe McKie Aug 14 '13 at 20:56

0 Answers0