Merge branch 'ja/do-not-ask-needless-questions'
[gitweb.git] / read-cache.c
index 3339de812460c903db085dc2be39e4c8b491478f..22ab8b5b61636cbc3bf8bcaf5a2ef964bf69c4c3 100644 (file)
@@ -1877,15 +1877,9 @@ int discard_index(struct index_state *istate)
 {
        int i;
 
-       for (i = 0; i < istate->cache_nr; i++) {
-               if (istate->cache[i]->index &&
-                   istate->split_index &&
-                   istate->split_index->base &&
-                   istate->cache[i]->index <= istate->split_index->base->cache_nr &&
-                   istate->cache[i] == istate->split_index->base->cache[istate->cache[i]->index - 1])
-                       continue;
+       unshare_split_index(istate, 1);
+       for (i = 0; i < istate->cache_nr; i++)
                free(istate->cache[i]);
-       }
        resolve_undo_clear_index(istate);
        istate->cache_nr = 0;
        istate->cache_changed = 0;