]> git.ipfire.org Git - thirdparty/git.git/commitdiff
name-hash: don't add directories to name_hash
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 12 Apr 2021 21:08:15 +0000 (21:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Apr 2021 20:47:51 +0000 (13:47 -0700)
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 <dstolee@microsoft.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
name-hash.c

index 4e03fac9bb12599d897cc54c7154eceab267784d..d08deaa2c9e7c514b4ffa366f39390565efe122c 100644 (file)
@@ -109,8 +109,11 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
        if (ce->ce_flags & CE_HASHED)
                return;
        ce->ce_flags |= CE_HASHED;
-       hashmap_entry_init(&ce->ent, memihash(ce->name, ce_namelen(ce)));
-       hashmap_add(&istate->name_hash, &ce->ent);
+
+       if (!S_ISSPARSEDIR(ce->ce_mode)) {
+               hashmap_entry_init(&ce->ent, memihash(ce->name, ce_namelen(ce)));
+               hashmap_add(&istate->name_hash, &ce->ent);
+       }
 
        if (ignore_case)
                add_dir_entry(istate, ce);