threads / bug / 42802

Git 2.8.1 - bug in patience diff algorithm when used with --ignore-space-at-eol?

Subject: Git 2.8.1 - bug in patience diff algorithm when used with --ignore-space-at-eol?

## tl;dr

3 messages between Jul 8, 2016 and Jul 9, 2016.

replies: 2people: 2as markdown or json

Naja Melan· Jul 8, 2016, 16:51 UTC · lore

When diffing with --patience and --ignore-space-at-eol, a change that adds or removes just one character a the end of a line isn't picked up.

Other diff algorithms don't suffer from this and patience doesn't if I don't put --ignore-space-at-eol.

See the following output for a proof:
$ git diff --ignore-space-at-eol lib/gitomate/facts/path.rb
diff --git a/lib/gitomate/facts/path.rb b/lib/gitomate/facts/path.rb
index bc99661..a5cd184 100644
--- a/lib/gitomate/facts/path.rb
+++ b/lib/gitomate/facts/path.rb
@@ -77,7 +77,7 @@ def check( update = false )
      options( :exist ) and warn "#{@info[ :path ].inspect} does not exist."
      options( :exist ) or  warn "#{@info[ :path ].inspect} exists but
it shouldn't."

-     @checked = true
+     @checked = trued
      return @checkPassed = false

   end

$ git diff --patience --ignore-space-at-eol lib/gitomate/facts/path.rb
-> no output

$ git diff --patience lib/gitomate/facts/path.rb

diff --git a/lib/gitomate/facts/path.rb b/lib/gitomate/facts/path.rb
index bc99661..a5cd184 100644
--- a/lib/gitomate/facts/path.rb
+++ b/lib/gitomate/facts/path.rb
@@ -77,7 +77,7 @@ def check( update = false )
      options( :exist ) and warn "#{@info[ :path ].inspect} does not exist."
      options( :exist ) or  warn "#{@info[ :path ].inspect} exists but
it shouldn't."

-     @checked = true
+     @checked = trued
      return @checkPassed = false

   end


Naja Melan
Johannes Schindelin· Jul 9, 2016, 06:24 UTC · re: Naja Melan · lore

Re: Git 2.8.1 - bug in patience diff algorithm when used with --ignore-space-at-eol?

Hi Naja,
On Fri, 8 Jul 2016, Naja Melan wrote:
> When diffing with --patience and --ignore-space-at-eol, a change that
> adds or removes just one character a the end of a line isn't picked up.

Confirmed with the current 'master'. I am on it, building on top of this diff:

-- snipsnap --
diff --git a/t/t4033-diff-patience.sh b/t/t4033-diff-patience.sh
index 3c9932e..6da435b 100755
--- a/t/t4033-diff-patience.sh
+++ b/t/t4033-diff-patience.sh
@@ -5,6 +5,13 @@ test_description='patience diff algorithm'
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-diff-alternative.sh
 
+test_expect_failure '--ignore-space-at-eol with a single appended character' '
+	printf "a\nb\nc\n" >pre &&
+	printf "a\nbX\nc\n" >post &&
+	git diff --no-index --patience --ignore-space-at-eol pre post >diff &&
+	grep "^+.*X" diff
+'
+
 test_diff_frobnitz "patience"
 
 test_diff_unique "patience"
Johannes Schindelin· Jul 9, 2016, 07:26 UTC · re: Johannes Schindelin · lore

Re: Git 2.8.1 - bug in patience diff algorithm when used with --ignore-space-at-eol?

Hi,
On Sat, 9 Jul 2016, Johannes Schindelin wrote:
Show 6 quoted lines
> On Fri, 8 Jul 2016, Naja Melan wrote:
> 
> > When diffing with --patience and --ignore-space-at-eol, a change that
> > adds or removes just one character a the end of a line isn't picked up.
> 
> Confirmed with the current 'master'. I am on it [...]
And I fixed it:
http://thread.gmane.org/gmane.comp.version-control.git/299176/focus=299178

Ciao, Johannes

← back to recent threads