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.