]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Name hash fixups: export (and rename) remove_hash_entry
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 23 Feb 2008 04:39:21 +0000 (20:39 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 23 Feb 2008 05:24:47 +0000 (21:24 -0800)
This makes the name hash removal function (which really just sets the
bit that disables lookups of it) available to external routines, and
makes read_cache_unmerged() use it when it drops an unmerged entry from
the index.

It's renamed to remove_index_entry(), and we drop the (unused) 'istate'
argument.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-read-tree.c
cache.h
read-cache.c

index 726fb0b588dcb550b5554b111a416c7ac3b25521..7bdc312e3861103fa83b20b939962a8bc8e6cc0a 100644 (file)
@@ -41,6 +41,7 @@ static int read_cache_unmerged(void)
        for (i = 0; i < active_nr; i++) {
                struct cache_entry *ce = active_cache[i];
                if (ce_stage(ce)) {
+                       remove_index_entry(ce);
                        if (last && !strcmp(ce->name, last->name))
                                continue;
                        cache_tree_invalidate_path(active_cache_tree, ce->name);
diff --git a/cache.h b/cache.h
index 0b69c92daa975d116c54e3b5000bc9a744a007dd..88d3b92d2ec7a8a601d84002a0c862b9db307548 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -137,6 +137,20 @@ struct cache_entry {
 #define CE_HASHED    (0x100000)
 #define CE_UNHASHED  (0x200000)
 
+/*
+ * We don't actually *remove* it, we can just mark it invalid so that
+ * we won't find it in lookups.
+ *
+ * Not only would we have to search the lists (simple enough), but
+ * we'd also have to rehash other hash buckets in case this makes the
+ * hash bucket empty (common). So it's much better to just mark
+ * it.
+ */
+static inline void remove_index_entry(struct cache_entry *ce)
+{
+       ce->ce_flags |= CE_UNHASHED;
+}
+
 static inline unsigned create_ce_flags(size_t len, unsigned stage)
 {
        if (len >= CE_NAMEMASK)
index eb58b03f952306a23e2458d856066e90532f0f4d..fee0c80734db2d5106c4c6fd6bc396af1831c392 100644 (file)
@@ -70,25 +70,11 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent
                hash_index_entry(istate, ce);
 }
 
-/*
- * We don't actually *remove* it, we can just mark it invalid so that
- * we won't find it in lookups.
- *
- * Not only would we have to search the lists (simple enough), but
- * we'd also have to rehash other hash buckets in case this makes the
- * hash bucket empty (common). So it's much better to just mark
- * it.
- */
-static void remove_hash_entry(struct index_state *istate, struct cache_entry *ce)
-{
-       ce->ce_flags |= CE_UNHASHED;
-}
-
 static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
 {
        struct cache_entry *old = istate->cache[nr];
 
-       remove_hash_entry(istate, old);
+       remove_index_entry(old);
        set_index_entry(istate, nr, ce);
        istate->cache_changed = 1;
 }
@@ -417,7 +403,7 @@ int remove_index_entry_at(struct index_state *istate, int pos)
 {
        struct cache_entry *ce = istate->cache[pos];
 
-       remove_hash_entry(istate, ce);
+       remove_index_entry(ce);
        istate->cache_changed = 1;
        istate->cache_nr--;
        if (pos >= istate->cache_nr)