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

Re: Horrible re-packing?

From
Junio C Hamano <junkio@cox.net>
Date
Jun 5, 2006, 19:37 UTC
Message-ID
<7vy7wb4cmy.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0606051155000.5498@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
Show 18 quoted lines
> I think the hash function with its comment is self-explanatory:
>
>         /*
>          * 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.
>          */
>         while ((c = *name++) != 0) {
>                 if (isspace(c))
>                         continue;
>                 hash = (hash >> 2) + (c << 24);
>         }
>         return hash;
>
> ie we just create a 32-bit hash, where we "age" previous characters by two 
> bits, so the last characters in a filename count most. So when we then 
> compare the hashes in the sort routine, filenames that end the same way 
> sort the same way.

IIRC, sometimes this function is called with path and name split and sometimes with full path in name, depending on who calls you (the latter happens for rev-list --object generated names, and the former is for objects we extract ourselves from the --thin base tree, or something like that). I suspect your patch may break paths whose filename after the last slash is shorter than 16 bytes.

Previous: Linus TorvaldsNext: Linus Torvalds
Message 4 of 15 in “Horrible re-packing?”
  1. Linus TorvaldsJun 5, 2006
  2. Linus TorvaldsJun 5, 2006
  3. Linus TorvaldsJun 5, 2006
  4. Junio C HamanoJun 5, 2006
  5. Linus TorvaldsJun 5, 2006
  6. Junio C HamanoJun 5, 2006
  7. Junio C HamanoJun 6, 2006
  8. Olivier GalibertJun 5, 2006
  9. Nicolas PitreJun 5, 2006
  10. Chris WedgwoodJun 6, 2006
  11. Linus TorvaldsJun 6, 2006
  12. Linus TorvaldsJun 5, 2006
  13. Nicolas PitreJun 5, 2006
  14. Linus TorvaldsJun 5, 2006
  15. Nicolas PitreJun 5, 2006

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.