summary refs log tree commit diff
path: root/split-index.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2017-02-27 19:00:01 +0100
committerJunio C Hamano <gitster@pobox.com>2017-03-01 13:24:21 -0800
commitcef4fc7ebe869e910d0fd5643cd60328ed76356a (patch)
tree1e2208e78fed34a57a6ddb43cfd301aafe24cda8 /split-index.c
parent1f44b09b5891aa0dc30cc7b7fff0d29b985a5af6 (diff)
split-index: add {add,remove}_split_index() functions
Also use the functions in cmd_update_index() in
builtin/update-index.c.

These functions will be used in a following commit to tweak
our use of the split-index feature depending on the setting
of a configuration variable.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'split-index.c')
-rw-r--r--split-index.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/split-index.c b/split-index.c
index 615f4cac05..f519e60f87 100644
--- a/split-index.c
+++ b/split-index.c
@@ -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;
+	}
+}