summary refs log tree commit diff
path: root/split-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-03-07 09:59:56 +0900
committerJunio C Hamano <gitster@pobox.com>2019-03-07 09:59:56 +0900
commit0efa3d74e705ed2c66c33854ac4bfd0d6c7f56de (patch)
treeef2634edad53b83fd6aea32a325da6a03d821149 /split-index.c
parentebf846c0086114714c0162c4dc8acbf344740c1d (diff)
parent6e37c8ed3c899385651f5beac1f1588fe3c1f5fb (diff)
Merge branch 'nd/split-index-null-base-fix'
Split-index fix.

* nd/split-index-null-base-fix:
  read-cache.c: fix writing "link" index ext with null base oid
Diffstat (limited to 'split-index.c')
-rw-r--r--split-index.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/split-index.c b/split-index.c
index 8aebc3661b..e6154e4ea9 100644
--- a/split-index.c
+++ b/split-index.c
@@ -440,24 +440,26 @@ void add_split_index(struct index_state *istate)
 void remove_split_index(struct index_state *istate)
 {
 	if (istate->split_index) {
-		/*
-		 * When removing the split index, we need to move
-		 * ownership of the mem_pool associated with the
-		 * base index to the main index. There may be cache entries
-		 * allocated from the base's memory pool that are shared with
-		 * the_index.cache[].
-		 */
-		mem_pool_combine(istate->ce_mem_pool, istate->split_index->base->ce_mem_pool);
+		if (istate->split_index->base) {
+			/*
+			 * When removing the split index, we need to move
+			 * ownership of the mem_pool associated with the
+			 * base index to the main index. There may be cache entries
+			 * allocated from the base's memory pool that are shared with
+			 * the_index.cache[].
+			 */
+			mem_pool_combine(istate->ce_mem_pool,
+					 istate->split_index->base->ce_mem_pool);
 
-		/*
-		 * The split index no longer owns the mem_pool backing
-		 * its cache array. As we are discarding this index,
-		 * mark the index as having no cache entries, so it
-		 * will not attempt to clean up the cache entries or
-		 * validate them.
-		 */
-		if (istate->split_index->base)
+			/*
+			 * The split index no longer owns the mem_pool backing
+			 * its cache array. As we are discarding this index,
+			 * mark the index as having no cache entries, so it
+			 * will not attempt to clean up the cache entries or
+			 * validate them.
+			 */
 			istate->split_index->base->cache_nr = 0;
+		}
 
 		/*
 		 * We can discard the split index because its