Skip to content

Commit 5f11669

Browse files
derrickstoleegitster
authored andcommitted
name-hash: don't add directories to name_hash
Sparse directory entries represent a directory that is outside the sparse-checkout definition. These are not paths to blobs, so should not be added to the name_hash table. Instead, they should be added to the directory hashtable when 'ignore_case' is true. Add a condition to avoid placing sparse directories into the name_hash hashtable. This avoids filling the table with extra entries that will never be queried. Signed-off-by: Derrick Stolee <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5fed74 commit 5f11669

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

name-hash.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
109109
if (ce->ce_flags & CE_HASHED)
110110
return;
111111
ce->ce_flags |= CE_HASHED;
112-
hashmap_entry_init(&ce->ent, memihash(ce->name, ce_namelen(ce)));
113-
hashmap_add(&istate->name_hash, &ce->ent);
112+
113+
if (!S_ISSPARSEDIR(ce->ce_mode)) {
114+
hashmap_entry_init(&ce->ent, memihash(ce->name, ce_namelen(ce)));
115+
hashmap_add(&istate->name_hash, &ce->ent);
116+
}
114117

115118
if (ignore_case)
116119
add_dir_entry(istate, ce);

0 commit comments

Comments
 (0)