awm
awm

Reputation: 1200

Git shows a line has been removed and added although nothing changed?

I work with Eclipse on Ubuntu. I have already gone through a lot of Eclipse configuration to get it to work properly (e.g., line endings, spaces, tabs, etc.). There is one thing that I cannot figure out what it is happening. When I do git diff:

-  $entity_info = entity_get_info($form['#entity_type']);  
+  $entity_info = entity_get_info($form['#entity_type']);

There are no changes, except perhaps, white space encoding? This does not show when I do git diff -w. What is actually happening? How do I get Eclipse not to do this?

Upvotes: 1

Views: 166

Answers (1)

Simon Boudrias
Simon Boudrias

Reputation: 44589

-w flag ignore whitespace. So this is a whitespace trouble, which can be a change from tab to space (and vice-versa) or you changed line ending, or you added trailing whitespace... etc

Windows and UNIX system don't use same line-ending, to prevent conflict from happening based on these, you should setup you git config this way:

  • Windows : git config --global core.autocrlf true
  • Unix : git config --global core.autocrlf input

Next, to make sure we only commit with ideal whitespace rules, you can set this config option:

git config --global core.whitespace trailing-space,space-before-tab,indent-with-non-tab

Upvotes: 1

Related Questions