git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3] name-hash: don't add sparse directories in threaded lazy init

From
Alex Mironov via GitGitGadget <gitgitgadget@gmail.com>
Date
May 21, 2025, 21:29 UTC
Message-ID
<pull.1970.v3.git.git.1747862971672.gitgitgadget@gmail.com>
In-Reply-To
<pull.1970.v2.git.git.1747858585623.gitgitgadget@gmail.com>
From: Alex Mironov <alexandrfox@gmail.com>

Ensure that logic added in 5f11669586 (name-hash: don't add directories to name_hash, 2021-04-12) also applies in multithreaded hashtable init path.

As per the original single-threaded change above: 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: Alex Mironov <alexandrfox@gmail.com>
---
    name-hash: don't add sparse directories in threaded lazy init
    
    Changes since v2:
    
     * addressed commit message structure
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1970%2Falexandrfox%2Ffix-threaded-hash-name-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1970/alexandrfox/fix-threaded-hash-name-v3
Pull-Request: https://github.com/git/git/pull/1970
Range-diff vs v2:
 1:  fb378147c73 ! 1:  b91ccb640c5 name-hash: don't add sparse directories in threaded lazy init
     @@ Commit message
          to name_hash, 2021-04-12) also applies in multithreaded hashtable init
          path.
      
     -    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 as they must never be queried.
     +    As per the original single-threaded change above: 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: Alex Mironov <alexandrfox@gmail.com>
      
 name-hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/name-hash.c b/name-hash.c
index d66de1cdfd5..b91e2762678 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -492,8 +492,10 @@ static void *lazy_name_thread_proc(void *_data)
 	for (k = 0; k < d->istate->cache_nr; k++) {
 		struct cache_entry *ce_k = d->istate->cache[k];
 		ce_k->ce_flags |= CE_HASHED;
-		hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
-		hashmap_add(&d->istate->name_hash, &ce_k->ent);
+		if (!S_ISSPARSEDIR(ce_k->ce_mode)) {
+			hashmap_entry_init(&ce_k->ent, d->lazy_entries[k].hash_name);
+			hashmap_add(&d->istate->name_hash, &ce_k->ent);
+		}
 	}
 
 	return NULL;

base-commit: 8613c2bb6cd16ef530dc5dd74d3b818a1ccbf1c0
-- 
gitgitgadget
Previous: Alex MironovNext: Junio C Hamano
Message 11 of 13 in “name-hash: don't add sparse directories in threaded lazy init”
  1. name-hash: don't add sparse directories in threaded lazy initAlex Mironov via GitGitGadget, May 21, 2025
  2. Derrick StoleeMay 21, 2025
  3. Junio C HamanoMay 21, 2025
  4. Alex MironovMay 21, 2025
  5. name-hash: don't add sparse directories in threaded lazy initAlex Mironov via GitGitGadget, May 21, 2025
  6. Junio C HamanoMay 21, 2025
  7. Alex MironovMay 21, 2025
  8. Junio C HamanoMay 21, 2025
  9. Junio C HamanoMay 21, 2025
  10. Alex MironovMay 21, 2025
  11. name-hash: don't add sparse directories in threaded lazy initAlex Mironov via GitGitGadget, May 21, 2025
  12. Junio C HamanoMay 21, 2025
  13. Derrick StoleeMay 22, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.