Matthieu Moy <Matthieu.Moy@xxxxxxx> writes: > - if (pos < 0) > - pos = -pos - 1; > - ce = active_cache[pos]; > - if (ce_namelen(ce) == namelen && > - !memcmp(ce->name, filename, namelen)) > + if (pos >= 0) { > + ce = active_cache[pos]; A positive return value of cache_name_pos() is "I found a merged entry with that name at this index" while a negative is "I would insert at this index if you give me a merged entry with that name". The latter is what the name comparison logic is about. The caller asked for filename, and the return value may point at an existing entry (in which case you do not even need to memcmp(), but it doesn't hurt and simplifies the code). The nagative one with compensation could be pointing at an unrelated entry, or an unmerged entry with filename you asked, which sorts higher than a merged entry with the same name. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html