dir: convert dir_add* to take an index
[gitweb.git] / split-index.c
index 35da553655bdf7b70519ecf529544796ca8185b5..f519e60f87578386ec9b4ea764bf530be0f64836 100644 (file)
@@ -187,7 +187,7 @@ void prepare_to_write_split_index(struct index_state *istate)
                /* Go through istate->cache[] and mark CE_MATCHED to
                 * entry with positive index. We'll go through
                 * base->cache[] later to delete all entries in base
-                * that are not marked eith either CE_MATCHED or
+                * that are not marked with either CE_MATCHED or
                 * CE_UPDATE_IN_BASE. If istate->cache[i] is a
                 * duplicate, deduplicate it.
                 */
@@ -317,3 +317,25 @@ void replace_index_entry_in_base(struct index_state *istate,
                istate->split_index->base->cache[new->index - 1] = new;
        }
 }
+
+void add_split_index(struct index_state *istate)
+{
+       if (!istate->split_index) {
+               init_split_index(istate);
+               istate->cache_changed |= SPLIT_INDEX_ORDERED;
+       }
+}
+
+void remove_split_index(struct index_state *istate)
+{
+       if (istate->split_index) {
+               /*
+                * can't discard_split_index(&the_index); because that
+                * will destroy split_index->base->cache[], which may
+                * be shared with the_index.cache[]. So yeah we're
+                * leaking a bit here.
+                */
+               istate->split_index = NULL;
+               istate->cache_changed |= SOMETHING_CHANGED;
+       }
+}