Re: Horrible re-packing?
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:28
Linus Torvalds [off-list ref] writes:
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.