git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Strange diff behavior?
@ 2007-06-21  1:02 Jason Sewall
  2007-06-21  1:13 ` Johannes Schindelin
  2007-06-21  6:50 ` Matthias Lederhofer
  0 siblings, 2 replies; 7+ messages in thread
From: Jason Sewall @ 2007-06-21  1:02 UTC (permalink / raw)
  To: git

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);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Strange diff behavior?
  2007-06-21  1:02 Strange diff behavior? Jason Sewall
@ 2007-06-21  1:13 ` Johannes Schindelin
  2007-06-21  6:47   ` Raimund Bauer
  2007-06-21  6:50 ` Matthias Lederhofer
  1 sibling, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2007-06-21  1:13 UTC (permalink / raw)
  To: Jason Sewall; +Cc: git

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Strange diff behavior?
  2007-06-21  1:13 ` Johannes Schindelin
@ 2007-06-21  6:47   ` Raimund Bauer
  2007-06-21 10:31     ` Johannes Schindelin
  0 siblings, 1 reply; 7+ messages in thread
From: Raimund Bauer @ 2007-06-21  6:47 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Jason Sewall, git

On Thu, 2007-06-21 at 02:13 +0100, Johannes Schindelin wrote:
> 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?

My guess: apply.whitespace=strip

> Ciao,
> Dscho

-- 
best regards

  Ray

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Strange diff behavior?
  2007-06-21  1:02 Strange diff behavior? Jason Sewall
  2007-06-21  1:13 ` Johannes Schindelin
@ 2007-06-21  6:50 ` Matthias Lederhofer
  2007-06-21  7:02   ` Jason Sewall
  1 sibling, 1 reply; 7+ messages in thread
From: Matthias Lederhofer @ 2007-06-21  6:50 UTC (permalink / raw)
  To: Jason Sewall; +Cc: git

Jason Sewall <jasonsewall@gmail.com> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Strange diff behavior?
  2007-06-21  6:50 ` Matthias Lederhofer
@ 2007-06-21  7:02   ` Jason Sewall
  0 siblings, 0 replies; 7+ messages in thread
From: Jason Sewall @ 2007-06-21  7:02 UTC (permalink / raw)
  To: git

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 <matled@gmx.net> wrote:
> Jason Sewall <jasonsewall@gmail.com> 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.
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Strange diff behavior?
  2007-06-21  6:47   ` Raimund Bauer
@ 2007-06-21 10:31     ` Johannes Schindelin
  2007-06-21 16:46       ` Jason Sewall
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2007-06-21 10:31 UTC (permalink / raw)
  To: Raimund Bauer; +Cc: Jason Sewall, git

Hi,

On Thu, 21 Jun 2007, Raimund Bauer wrote:

> On Thu, 2007-06-21 at 02:13 +0100, Johannes Schindelin wrote:
> 
> > Just a guess: core.autocrlf=true?
> 
> My guess: apply.whitespace=strip

Much better guess, I guess. Jason?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Strange diff behavior?
  2007-06-21 10:31     ` Johannes Schindelin
@ 2007-06-21 16:46       ` Jason Sewall
  0 siblings, 0 replies; 7+ messages in thread
From: Jason Sewall @ 2007-06-21 16:46 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Raimund Bauer, git

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 <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Thu, 21 Jun 2007, Raimund Bauer wrote:
>
> > On Thu, 2007-06-21 at 02:13 +0100, Johannes Schindelin wrote:
> >
> > > Just a guess: core.autocrlf=true?
> >
> > My guess: apply.whitespace=strip
>
> Much better guess, I guess. Jason?
>
> Ciao,
> Dscho
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-06-21 16:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21  1:02 Strange diff behavior? Jason Sewall
2007-06-21  1:13 ` Johannes Schindelin
2007-06-21  6:47   ` Raimund Bauer
2007-06-21 10:31     ` Johannes Schindelin
2007-06-21 16:46       ` Jason Sewall
2007-06-21  6:50 ` Matthias Lederhofer
2007-06-21  7:02   ` Jason Sewall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).