Strange diff behavior?

Subsystems: the rest

7 messages, 4 authors, 2016-06-15 · open the first message on its own page

Strange diff behavior?

From: Jason Sewall <hidden>
Date: 2016-06-15 22:43:17

I'm pretty new to git, but I've been using it a lot recently and I'm
really liking it.

I do have a question that I'm 99% sure is a stupid one but I'd like an
answer anyway.

I recently make a few simple changes to a working directory, and
decided to do a diff before I committed it.

The results were something like the diff at the end of this email.

It seems like every change listed after the first one is meaningless.
I really think I just don't understand something about the diff
algorithm. Can someone tell my why those empty lines are recorded as
changes?

Jason

P.S. git diff --check is empty; there's no whitespace on those lines

P.P.S. The diff:
diff --git a/mac.cpp b/mac.cpp
index 02aab7b..34c510b 100644
--- a/mac.cpp
+++ b/mac.cpp
@@ -80,10 +80,10 @@ float grid::bilerp(const uVec & lower, const Vec &
inpos) const
     idx[0] += 1;
     vals[3] = (*this)(idx); // 1, 1

-    float low_val = lerp(pos[0], vals[0], vals[1]);
-    float high_val = lerp(pos[0], vals[2], vals[3]);
+    float low_val = cog::lerp(pos[0], vals[0], vals[1]);
+    float high_val = cog::lerp(pos[0], vals[2], vals[3]);

-    return lerp(pos[1], low_val, high_val);
+    return cog::lerp(pos[1], low_val, high_val);
 }

 float grid::max() const
@@ -194,7 +194,7 @@ mac_grid::mac_grid(const Vec & low, const Vec &
high, unsigned int dim) : low_bo

         for(idx[0] = (dim_-1)/4+1; idx[0] < 3*(dim_-1)/4; idx[0]++)
             cell_type(idx) = SOLID;
-
+
         for(idx[0] = 3*(dim_-1)/4+1; idx[0] < (dim_-1); idx[0]++)
             cell_type(idx) = SOLID;
     }
@@ -636,7 +636,7 @@ void mac_grid::printA(std::ostream & out)
     out << "sparse(";

     iVec idx;
-
+
     out << "[";
     for(idx[1] = 0; idx[1] < static_cast<int>(dim_); idx[1]++)
         for(idx[0] = 0; idx[0] < static_cast<int>(dim_); idx[0]++)
@@ -645,7 +645,7 @@ void mac_grid::printA(std::ostream & out)
             iVec e(idx + iVec(1, 0));
             iVec s(idx - iVec(0, 1));
             iVec n(idx + iVec(0, 1));
-
+
             if(w[0] > 0)
                 out << row_major_idx(idx, Adiag_.dim_)+1 <<",";
             if(s[1] > 0)
@@ -654,7 +654,7 @@ void mac_grid::printA(std::ostream & out)
                 out << row_major_idx(idx, Adiag_.dim_)+1 <<",";
             if(n[1] < static_cast<int>(dim_))
                 out << row_major_idx(idx, Adiag_.dim_)+1 <<",";
-
+
             out << row_major_idx(idx, Adiag_.dim_)+1 <<",";
         }
@@ -742,7 +742,7 @@ float mac_grid::dot(const grid & l, const grid & r) const
         for(idx[0] = 1; idx[0] < dim_-1; idx[0]++)
             if(cell_type(idx) == FLUID)
                 res += l(idx)*r(idx);
-
+
     return res;
 }
@@ -903,7 +903,7 @@ void mac_grid::construct_pc()
                 {
                     float sfact = Aplusj_(s)*pc_(s);
                     ichol += sfact*sfact;
-
+
                     float wfact = Aplusi_(w)*pc_(w);
                     ichol += wfact*wfact;
                 }
@@ -940,7 +940,7 @@ void mac_grid::apply_pc(const grid & rhs, grid & res)
         {
             uVec s(idx-uVec(0, 1));
             uVec w(idx-uVec(1, 0));
-
+
             float t = rhs(idx);
             if(cell_type(s) == FLUID)
                 t -= Aplusj_(s)*pc_(s)*q_(s);

Re: Strange diff behavior?

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:17

Hi,

On Wed, 20 Jun 2007, Jason Sewall wrote:
It seems like every change listed after the first one is meaningless.
Just a guess: core.autocrlf=true?

Ciao,
Dscho

Re: Strange diff behavior?

From: Raimund Bauer <hidden>
Date: 2016-06-15 22:43:17

On Thu, 2007-06-21 at 02:13 +0100, Johannes Schindelin wrote:
Hi,

On Wed, 20 Jun 2007, Jason Sewall wrote:
quoted
It seems like every change listed after the first one is meaningless.
Just a guess: core.autocrlf=true?
My guess: apply.whitespace=strip
Ciao,
Dscho
-- 
best regards

  Ray

Re: Strange diff behavior?

From: Matthias Lederhofer <hidden>
Date: 2016-06-15 22:43:17

Jason Sewall [off-list ref] wrote:
It seems like every change listed after the first one is meaningless.
I really think I just don't understand something about the diff
algorithm. Can someone tell my why those empty lines are recorded as
changes?
This are whitespace changes.

    $ git diff --color

marks whitespaces at the end of the line with a red background color
so you can see what changed.  I also use vim with :set list to see
whitespace changes, e.g.

    $ git diff | vim -c 'set list' -

If you like to have colors (not just in diff) permnanently you can add
this to your .git/config or ~/.gitconfig:

    [color]
        branch = auto
        diff = auto
        status = auto
        pager = true

See also git-config(1) for more information on these and other
configuration options.

Re: Strange diff behavior?

From: Jason Sewall <hidden>
Date: 2016-06-15 22:43:17

As I mentioned in the ps, I git-diff --check shows nothing. As a
matter of fact, I do have color turned on and the pluses are green and
minuses red, but there are none of the characteristic red blocks that
trailing whitespace makes.

On 6/20/07, Matthias Lederhofer [off-list ref] wrote:
Jason Sewall [off-list ref] wrote:
quoted
It seems like every change listed after the first one is meaningless.
I really think I just don't understand something about the diff
algorithm. Can someone tell my why those empty lines are recorded as
changes?
This are whitespace changes.

    $ git diff --color

marks whitespaces at the end of the line with a red background color
so you can see what changed.  I also use vim with :set list to see
whitespace changes, e.g.

    $ git diff | vim -c 'set list' -

If you like to have colors (not just in diff) permnanently you can add
this to your .git/config or ~/.gitconfig:

    [color]
        branch = auto
        diff = auto
        status = auto
        pager = true

See also git-config(1) for more information on these and other
configuration options.

Re: Strange diff behavior?

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:17

Hi,

On Thu, 21 Jun 2007, Raimund Bauer wrote:
On Thu, 2007-06-21 at 02:13 +0100, Johannes Schindelin wrote:
quoted
Just a guess: core.autocrlf=true?
My guess: apply.whitespace=strip
Much better guess, I guess. Jason?

Ciao,
Dscho

Re: Strange diff behavior?

From: Jason Sewall <hidden>
Date: 2016-06-15 22:43:17

Ok, it was my bad. There *were* whitespaces on those lines, but in
HEAD^, not head. Git only cares when they are introduced, not when
they are removed. So git diff HEAD^..HEAD showed that strange line
removal/add but git diff HEAD..HEAD^ shows me the whitespace.

I recently set up emacs to strip whitespace whenever I save a file to
prevent git from complaining (and it's good practice anyway), so that
explains why I didn't expect the change

Sorry about the mixup, and thanks for your help.

On 6/21/07, Johannes Schindelin [off-list ref] wrote:
Hi,

On Thu, 21 Jun 2007, Raimund Bauer wrote:
quoted
On Thu, 2007-06-21 at 02:13 +0100, Johannes Schindelin wrote:
quoted
Just a guess: core.autocrlf=true?
My guess: apply.whitespace=strip
Much better guess, I guess. Jason?

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help