Search code examples
gitgit-diff

git diff - appears no change, but shows changes


I was messing around and saw something odd. I think this started when I recently enabled strip whitespace in my IDE. When I do a git diff, I'm now getting something like this:

@@ -106,8 +106,8 @@ dashboard.run(function($rootScope) {
             learnedOfFrom: 'sum'
         },
         {
-            docID: 1011, 
-            fullName: 'Lorem', 
+            docID: 1011,
+            fullName: 'Lorem',

I'm betting the "-" lines had a space at the end, that would normally show as a red block, and my IDE stripped them out on save, but for some reason that's not showing. Has anyone else run into this? I thought it was odd. This is the first time I've run across seeing "-" and "+" where the code looks identical and if it was trailing spaces getting stripped then I'm surprised git diff isn't showing big red blocks like usual.


Solution

  • If you look at that diff closely, and check for whitespace, you can see that the removed lines have a trailing space, and the added lines no longer do that.

    So the change is basically that trailing whitespace is removed.

    This would be the diff with spaces replaced by · for visibility:

    -············docID:·1011,·
    -············fullName:·'Lorem',·
    +············docID:·1011,
    +············fullName:·'Lorem',