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

Re: [PATCH v3 7/8] name-hash: allow dir hashing even when !ignore_case

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 9, 2014, 17:49 UTC
Message-ID
<xmqq8ulslm4n.fsf@gitster.dls.corp.google.com>
In-Reply-To
<4d43fca586637dcb02b2b19c8d8a6dcfe368e059.1409860234.git.tr@thomasrast.ch>
Thomas Rast <tr@thomasrast.ch> writes:
Show 43 quoted lines
> The directory hash (for fast checks if the index already has a
> directory) was only used in ignore_case mode and so depended on that
> flag.
>
> Make it generally available on request.
>
> Signed-off-by: Thomas Rast <tr@thomasrast.ch>
> ---
>  cache.h     |  2 ++
>  name-hash.c | 13 ++++++++-----
>  2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index 4d5b76c..c54b2e1 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -306,6 +306,7 @@ struct index_state {
>  	struct split_index *split_index;
>  	struct cache_time timestamp;
>  	unsigned name_hash_initialized : 1,
> +		 has_dir_hash : 1,
>  		 initialized : 1;
>  	struct hashmap name_hash;
>  	struct hashmap dir_hash;
> @@ -315,6 +316,7 @@ struct index_state {
>  extern struct index_state the_index;
>  
>  /* Name hashing */
> +extern void init_name_hash(struct index_state *istate, int force_dir_hash);
>  extern void add_name_hash(struct index_state *istate, struct cache_entry *ce);
>  extern void remove_name_hash(struct index_state *istate, struct cache_entry *ce);
>  extern void free_name_hash(struct index_state *istate);
> diff --git a/name-hash.c b/name-hash.c
> index 702cd05..22e3ec6 100644
> --- a/name-hash.c
> +++ b/name-hash.c
> @@ -106,7 +106,7 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
>  	hashmap_entry_init(ce, memihash(ce->name, ce_namelen(ce)));
>  	hashmap_add(&istate->name_hash, ce);
>  
> -	if (ignore_case)
> +	if (istate->has_dir_hash)
>  		add_dir_entry(istate, ce);

This smells more like needs_dir_hash than has_dir_hash to me. For ignore-case, we need dir_hash to make sure we do not end up adding two entries that cannot be represented on the filesystem.

Previous: Thomas RastNext: Thomas Rast
Message 14 of 18 in “--remerge-diff”
  1. 0/8 --remerge-diffThomas Rast, Sep 6, 2014
  2. 1/8 merge-recursive: remove dead conditional in update_stages()Thomas Rast, Sep 6, 2014
  3. 2/8 merge-recursive: internal flag to avoid touching the worktreeThomas Rast, Sep 6, 2014
  4. Junio C HamanoSep 8, 2014
  5. 3/8 merge-recursive: -Xindex-only to leave worktree unchangedThomas Rast, Sep 6, 2014
  6. 4/8 combine-diff: do not pass revs->dense_combined_merges redundantlyThomas Rast, Sep 6, 2014
  7. Junio C HamanoSep 8, 2014
  8. Jens LehmannSep 11, 2014
  9. 5/8 Fold all merge diff variants into an enumThomas Rast, Sep 6, 2014
  10. Junio C HamanoSep 8, 2014
  11. 6/8 merge-recursive: allow storing conflict hunks in indexThomas Rast, Sep 6, 2014
  12. Junio C HamanoSep 9, 2014
  13. 7/8 name-hash: allow dir hashing even when !ignore_caseThomas Rast, Sep 6, 2014
  14. Junio C HamanoSep 9, 2014
  15. 8/8 log --remerge-diff: show what the conflict resolution changedThomas Rast, Sep 6, 2014
  16. Junio C HamanoSep 8, 2014
  17. Junio C HamanoSep 9, 2014
  18. Junio C HamanoSep 9, 2014

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.