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

Re: possible Improving diff algoritm

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 13, 2012, 06:26 UTC
Message-ID
<7vzk1izcv6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<B1564B28-9BB9-48A2-B59E-7D7C0B0DDECF@adacore.com>
Geert Bosch <bosch@adacore.com> writes:
> It would seem that just looking at the line length (stripped) of
> the last line, might be sufficient for cost function to minimize.
> Here the some would be 3 vs 0. In case of ties, use the last
> possibility with minimum cost.

-- 8< -- #ifdef A

some stuff about A

#endif #ifdef Z

some more stuff about Z

#endif -- >8 --

If you insert a block for M following the existing formatting convention in the middle, your heuristics will pick the blank line after "about A" as having minimum cost, no?

You inherently have to know the nature of the payload, as your eyes that judge the result use that knowledge when doing so, I am afraid. I think your "define a function that gives a good score to lines that are likely to be good breaking points" idea has merit, but I think that should be tied to the content type, most likely via the attribute mechanism.

In any case, I consider this as a low-impact (as Michael Haggerty noted, it is impossible to introduce a bug that subtly break the output; your result is either totally borked or is correct) and low-hanging fruit (it can be done as a postprocessing phase after the xdiff machinery has done the heavy-lifting of computing LCA), if somebody wants to experiment and implement one. As long as the new heuristics is hidden behind an explicit command line option to avoid other "consequences", I wouldn't discourage interested parties from working on it. It is not just my itch, though.

Previous: Geert BoschNext: Javier Domingo
Message 15 of 18 in “Fwd: possible Improving diff algoritm”
  1. KevinDec 12, 2012
  2. Junio C HamanoDec 12, 2012
  3. Brian J. MurrellDec 12, 2012
  4. KevinDec 12, 2012
  5. Junio C HamanoDec 12, 2012
  6. Morten WelinderDec 12, 2012
  7. Junio C HamanoDec 12, 2012
  8. Andrew ArdillDec 12, 2012
  9. Javier DomingoDec 12, 2012
  10. Junio C HamanoDec 12, 2012
  11. Javier DomingoDec 12, 2012
  12. Michael HaggertyDec 13, 2012
  13. Morten WelinderDec 13, 2012
  14. Geert BoschDec 13, 2012
  15. Junio C HamanoDec 13, 2012
  16. Javier DomingoDec 14, 2012
  17. Bernhard R. LinkDec 14, 2012
  18. Javier DomingoDec 15, 2012

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.