Git diff is not comparing as expected

I have two files:

one.txt:

function drawLabel(l, inheritObj){
if(def(inheritObj)) l = [l, inheritObj];
l = unpack(l);
// alert('label object before defaults: '+l)

      

two.txt:

function drawLabel(l, inheritObj){
if(def(inheritObj)) l = [l, inheritObj];
l = unpack(l);
// alert('label object before defaults: '+l)

      

I tried to use git diff one.txt two.txt

on them. I expected this to tell me NO DIFFERENCE. Instead, he said the following:

diff --git a/one.txt b/two.txt
index 641c1d0..3a99d19 100644
--- a/one.txt
+++ b/two.txt
@@ -1,4 +1,4 @@
-function drawLabel(l, inheritObj){
-    if(def(inheritObj)) l = [l, inheritObj];
-    l = unpack(l);
-    // alert('label object before defaults: '+l)
+function drawLabel(l, inheritObj){
+    if(def(inheritObj)) l = [l, inheritObj];
+    l = unpack(l);
+    // alert('label object before defaults: '+l)

      

Not useful at all. I needed to compare two large files to find the differences. I thought git diff would find the differences and show them to me (and nothing else).

How can I get the behavior I expect?

+3


source to share


2 answers


It turns out using diff -w

or diff -b

showing that they are the same. So I must conclude that there is some strange difference in the new line that I cannot see.

Using regular diff

versus prettier git diff

didn't make a significant difference in this scenario. I tested both in all cases and they behaved the same.



Thanks everyone!

0


source


Are there some invisible characters like at the end of each line?

http://www.codealpha.net/514/diff-and-ignoring-spaces-and-end-of-lines-unix-dos-eol/



edit: okay, this is git diff -w

0


source







All Articles