git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re* [BUG-ish] diff compaction heuristic false positive

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2016, 18:13 UTC
Message-ID
<xmqqeg84gbex.fsf_-_@gitster.mtv.corp.google.com>
In-Reply-To
<CA+P7+xp=bTPiwRRTH=h7v5pV8+=he4+789_3PNz227mv1387MA@mail.gmail.com>
Jacob Keller <jacob.keller@gmail.com> writes:
Show 10 quoted lines
> I think we could use the indentation trick and it might help in this
> case. I agree, let's disable this for this cycle and experiment in the
> next one. Good catch, Peff.
>
> As others have said you will always be able to produce counter
> examples, that's the nature of heuristics. The idea is to see if we
> can come up with something simple that mostly improves the output,
> even if sometimes it might have a negative impact on the outputs. But
> I think we should avoid changing behavior unless it's mostly an
> improvement.

OK, let's do this then for the upcoming release for now. I am tempted to flip it back on after the release in 'next', so that developers would be exposed to the heuristic by default, though.

-- >8 --
Subject: [PATCH] diff: disable compaction heuristic for now

http://lkml.kernel.org/g/20160610075043.GA13411@sigill.intra.peff.net reports that a change to add a new "function" with common ending with the existing one at the end of the file is shown like this:

    def foo
      do_foo_stuff()
   +  common_ending()
   +end
   +
   +def bar
   +  do_bar_stuff()
   +
      common_ending()
    end

when the new heuristic is in use. In reality, the change is to add the blank line before "def bar" and everything below, which is what the code without the new heuristic shows.

Disable the heuristics by default and leave it as an experimental feature for now.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/diff.c b/diff.c
index 05ca3ce..9116d9d 100644
--- a/diff.c
+++ b/diff.c
@@ -25,7 +25,7 @@
 #endif
 
 static int diff_detect_rename_default;
-static int diff_compaction_heuristic = 1;
+static int diff_compaction_heuristic; /* experimental */
 static int diff_rename_limit_default = 400;
 static int diff_suppress_blank_empty;
 static int diff_use_color_default = -1;
-- 
2.9.0-rc2-275-g493bdbb
Previous: Jacob KellerNext: Stefan Beller
Message 6 of 16 in “[BUG-ish] diff compaction heuristic false positive”
  1. Jeff KingJun 10, 2016
  2. Jeff KingJun 10, 2016
  3. Junio C HamanoJun 10, 2016
  4. Stefan BellerJun 10, 2016
  5. Jacob KellerJun 10, 2016
  6. Re* [BUG-ish] diff compaction heuristic false positiveJunio C Hamano, Jun 10, 2016
  7. Stefan BellerJun 10, 2016
  8. Jeff KingJun 10, 2016
  9. diff: disable compaction heuristic for nowJunio C Hamano, Jun 10, 2016
  10. Jeff KingJun 10, 2016
  11. Junio C HamanoJun 10, 2016
  12. Jeff KingJun 10, 2016
  13. Junio C HamanoJun 10, 2016
  14. Michael HaggertyJun 10, 2016
  15. Jeff KingJun 10, 2016
  16. Michael HaggertyJun 10, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.