From: Jeff King Date: Fri, 10 Jun 2016 07:50:43 GMT Subject: [BUG-ish] diff compaction heuristic false positive Message-ID: <20160610075043.GA13411@sigill.intra.peff.net> I found a false positive with the new compaction heuristic in v2.9: -- >8 -- # start with a simple file cat >file.rb <<\EOF def foo do_foo_stuff() common_ending() end EOF git add file.rb git commit -m base # and then add another function with a similar ending cat >>file.rb <<\EOF def bar do_bar_stuff() common_ending() end EOF -- 8< -- I get this rather unfortunate diff: $ git diff diff --git a/file.rb b/file.rb index bd9d1cb..67fbeba 100644 --- a/file.rb +++ b/file.rb @@ -1,5 +1,11 @@ def foo do_foo_stuff() + common_ending() +end + +def bar + do_bar_stuff() + common_ending() end but without the compaction heuristic (or with an older git), I get: $ git -c diff.compactionHeuristic=false diff diff --git a/file.rb b/file.rb index bd9d1cb..67fbeba 100644 --- a/file.rb +++ b/file.rb @@ -3,3 +3,9 @@ def foo common_ending() end + +def bar + do_bar_stuff() + + common_ending() +end :( The problem is that the common bits are separated from the interesting bits by a blank line. This is simplified from a real-world example, but I think you could come up with the same example in C, like: if (foo) { do_foo(); something_else(); } -Peff