Jeremiah Mahler [off-list ref] writes:
We often represent our strings as a counted string, i.e. a pair of the
pointer to the beginning of the string and its length, and the string
may not be NUL terminated to that length.
To compare a pair of such counted strings, unpack-trees.c and
read-cache.c implement their own name_compare() functions identically.
In addition, the cache_name_compare() function in read-cache.c is nearly
identical. The only difference is when one string is the prefix of the
other string, in which case the former returns -1/+1 to show which one
is longer and the latter returns the difference of the lengths to show
the same information.
I think I got the former/latter swapped by mistake when I wrote this
(two name_compare() give us the difference, and cache_name_compare()
gives -1/+1); I'll spell their names out when I queue this patch.
Thanks.