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

Re: move detection doesnt take filename into account

From
Jeff King <peff@peff.net>
Date
Jul 9, 2014, 22:03 UTC
Message-ID
<20140709220337.GF25854@sigill.intra.peff.net>
In-Reply-To
<xmqqegxu7cpg.fsf@gitster.dls.corp.google.com>
On Wed, Jul 09, 2014 at 08:51:07AM -0700, Junio C Hamano wrote:
Show 17 quoted lines
> > The delta heuristics in pack-objects use pack_name_hash, which claims:
> >
> >         /*
> >          * This effectively just creates a sortable number from the
> >          * last sixteen non-whitespace characters. Last characters
> >          * count "most", so things that end in ".c" sort together.
> >          */
> >
> > which might be another option (and seems like a superset of the basename
> > check, short of basenames that are longer than 16 characters).
> 
> Perhaps.
> 
> I am however not sure if the code to compute similarity score is as
> OK with false positives, i.e. dissimilar names that happen to hash
> together getting clumped in a same bin or in close bins, as the
> existing callers of pack_name_hash().

I think the hash here does not collide in that way. It really is just the last sixteen characters shoved into a uint32_t.

But thinking on it more, that is useful to the delta code because it wants to create a sorted list of items. In the rename code we are doing pairwise comparisons, so we are more flexible. We can compare whole basenames, or whole suffixes (so "a/foo/bar.c" is closer to "b/foo/bar.c" than to "c/other/bar.c"). Or just use a general-purpose edit-distance function.

The tricky part is that the rename detection seems to take the score as a binary 0/1 "is it the same", but we would want to express more nuance (i.e., the "best" match among those that have similar content scores).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 11 in “move detection doesnt take filename into account”
  1. Elliot WolkJun 30, 2014
  2. Robin RosenbergJul 1, 2014
  3. Elliot WolkJul 1, 2014
  4. Junio C HamanoJul 1, 2014
  5. Elliot WolkJul 1, 2014
  6. Junio C HamanoJul 1, 2014
  7. Jeff KingJul 9, 2014
  8. Junio C HamanoJul 9, 2014
  9. Jeff KingJul 9, 2014
  10. Junio C HamanoJul 9, 2014
  11. Jeff KingJul 10, 2014

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.