split-index: do not invalidate cache-tree at read time
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 13 Jun 2014 12:19:42 +0000 (19:19 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Jun 2014 18:49:41 +0000 (11:49 -0700)
We are sure that after merge_base_index() is done. cache-tree can
still be used with the final index. So don't destroy cache tree.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
read-cache.c
split-index.c
diff --git a/cache.h b/cache.h
index 295bf9da5b9f7f8b386ab01df638e1d4aaf0f1e1..70fd8ed46219b1730971a89242b128be52828690 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -488,6 +488,7 @@ extern int index_name_pos(const struct index_state *, const char *name, int name
 #define ADD_CACHE_SKIP_DFCHECK 4       /* Ok to skip DF conflict checks */
 #define ADD_CACHE_JUST_APPEND 8                /* Append only; tree.c::read_tree() */
 #define ADD_CACHE_NEW_ONLY 16          /* Do not replace existing ones */
+#define ADD_CACHE_KEEP_CACHE_TREE 32   /* Do not invalidate cache-tree */
 extern int add_index_entry(struct index_state *, struct cache_entry *ce, int option);
 extern void rename_index_entry_at(struct index_state *, int pos, const char *new_name);
 extern int remove_index_entry_at(struct index_state *, int pos);
index 1a7ef7f7835186cead47fcaf8ee467394bc5f334..d5f70a08b9d475eaf80f9df3aeba524b8fde6cbe 100644 (file)
@@ -950,7 +950,8 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
        int skip_df_check = option & ADD_CACHE_SKIP_DFCHECK;
        int new_only = option & ADD_CACHE_NEW_ONLY;
 
-       cache_tree_invalidate_path(istate, ce->name);
+       if (!(option & ADD_CACHE_KEEP_CACHE_TREE))
+               cache_tree_invalidate_path(istate, ce->name);
        pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce));
 
        /* existing match? Just replace it. */
index b03a250e7cb9072aae525e646184239111f09c3f..33c0c4b6983f29bf29a4bcca9706180bd32b59ff 100644 (file)
@@ -133,6 +133,7 @@ void merge_base_index(struct index_state *istate)
        for (i = si->nr_replacements; i < si->saved_cache_nr; i++) {
                add_index_entry(istate, si->saved_cache[i],
                                ADD_CACHE_OK_TO_ADD |
+                               ADD_CACHE_KEEP_CACHE_TREE |
                                /*
                                 * we may have to replay what
                                 * merge-recursive.c:update_stages()