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

Re: [PATCH] Ignore end-of-line style when computing similarity score for rename detection

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jun 28, 2007, 06:18 UTC
Message-ID
<20070628061821.GM32223@spearce.org>
In-Reply-To
<20070628060416.GA13162@midwinter.com>
Steven Grimm <koreth@midwinter.com> wrote:
Show 7 quoted lines
> Junio rightly points out that it would be a mistake to discard \r
> characters from binary files when computing similarity scores. So now we
> only do it if the file contents test as non-binary.
> 
> The file attributes aren't available at this level of the code, but they
> could be propagated down from the higher levels if we don't trust
> buffer_is_binary() to make an adequately accurate decision.

Ick. If we can get the attributes into diff_filespec this is pretty easy, as you can do a crlf->lf conversion on both files if both are considered to be text, but it doesn't look like it would be very easy to get the attributes into the diff_filespec.

Actually even better if you can also run the in/out filter things. I'm thinking of say an XML file that has had whitespace formatting changes, but whose XSD and processors ignore unnecessary whitespace. Be nice if the rename detection actually was able to canonicalize both files before detecting the rename, assuming both files had a canonicalizer input filter defined that does that...

Of course diff.c defines a nice diff_is_binary() at file scope that does at least a "can we diff this" decision. Might be good if that could be reused for the rename detection.

OK, that's far more than I actually know about diffcore. This is one for Junio, Linus, you, and those who are less tired than I feel right now... ;-)

Personally I'd rather see us doing the right thing (use attributes and fallback on guessing if no preference is stated either way) over doing something half-a**ed (only guessing).

-- 
Shawn.
Previous: Steven GrimmNext: Junio C Hamano
Message 7 of 11 in “Ignore end-of-line style when computing similarity score for rename detection”
  1. Ignore end-of-line style when computing similarity score for rename detectionSteven Grimm, Jun 28, 2007
  2. Ignore end-of-line style when computing similarity score for rename detectionSteven Grimm, Jun 28, 2007
  3. Johannes SixtJun 28, 2007
  4. Junio C HamanoJun 28, 2007
  5. Junio C HamanoJun 28, 2007
  6. Ignore end-of-line style when computing similarity score for rename detectionSteven Grimm, Jun 28, 2007
  7. Shawn O. PearceJun 28, 2007
  8. Junio C HamanoJun 29, 2007
  9. Johannes SchindelinJun 28, 2007
  10. Steven GrimmJun 28, 2007
  11. Johannes SchindelinJun 29, 2007

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.