git diff, shows the same line as both deleted and added

I accidently worked on the master where I had to open up a new branch.

I reverted it to its original form almost completely. At one class I get the following diff that I can not make sense out of.

index 4a9abb8..7c55879 100755
--- a/includes/site.inc.php
+++ b/includes/site.inc.php
@@ -142,11 +142,11 @@ class site{

        public $tplEngine = 'smarty';

-
+       
     private $_productsByType = array();
     private $logger;
-    protected $locale = 'tr_TR';
-
+    protected $locale = 'tr_TR';  
+    

It says that I have deleted and added the same thing, in principle there is no difference with the original index and I don't want this file to be seen as modified.

What should I do ? Thx.

Answers


Check spaces. The replaced "empty" looking lines have spaces in them. You may also have accidentally replaced tabs with spaces or vice versa.


It's probably whitespace changes. You can run git diff -w, which will ignore any whitespace changes.


Check for spaces or line ending differences.


The second version of the nonblank line has a space after the semicolon and the blank lines also have different numbers of spaces.

There should be an option to have git highlight such hidden spaces so the diffs are more informative, but I don't have the manual handy.


In addition to spaces/tabs, line endings when entered from different editors (even on Windows) and/or different OSs can contribute to diff lines showing duplicates; LF (linux/Unix) vs CRLF (Windows).


Note that git 1.8.4 (July 2013) will no longer show you changes with only empty lines, if you are using the new -B option.

"git diff" learned a mode that ignores hunks whose change consists only of additions and removals of blank lines, which is the same as "diff -B" (ignore blank lines) of GNU diff.

See commit 36617af7ed594d1928554356d809bd611c642dd2:

The goal of the patch is to introduce the GNU diff -B/--ignore-blank-lines as closely as possible. The short option is not available because it's already used for "break-rewrites".

When this option is used, git diff will not create hunks that simply add or remove empty lines, but will still show empty lines addition/suppression if they are close enough to "valuable" changes.

here is a more thorough description of the option:

  • real changes are interesting
  • blank lines that are close enough (less than context size) to interesting changes are considered interesting (recursive definition)
  • "context" lines are used around each hunk of interesting changes
  • If two hunks are separated by less than "inter-hunk-context", they will be merged into one.

Need Your Help

Fancy Media Queries with some LESS Magic

css3 responsive-design less media-queries

It would be nice to wrap css-styles for different resolutions within some css-classes using less.

Callback When DialogFragment is Dismissed

android dialog

I want to launch a dialog with a custom layout, which I've implemented via a DialogFragment. (I basically just changed onCreateView() and added button handlers). The dialog lets the user quickly ch...