From: Junio C Hamano Date: Mon, 29 May 2017 03:34:43 +0000 (+0900) Subject: Merge branch 'nd/split-index-unshare' X-Git-Tag: v2.14.0-rc0~167 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f382b756a67e9c9e57fb4d4f07513cc9acd1aae9?ds=inline;hp=-c Merge branch 'nd/split-index-unshare' Plug some leaks and updates internal API used to implement the split index feature to make it easier to avoid such a leak in the future. * nd/split-index-unshare: p3400: add perf tests for rebasing many changes split-index: add and use unshare_split_index() --- f382b756a67e9c9e57fb4d4f07513cc9acd1aae9 diff --combined read-cache.c index 3339de8124,8da84ae2d1..22ab8b5b61 --- a/read-cache.c +++ b/read-cache.c @@@ -1877,15 -1877,9 +1877,9 @@@ int discard_index(struct index_state *i { 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; @@@ -2197,7 -2191,6 +2191,7 @@@ static int do_write_index(struct index_ int entries = istate->cache_nr; struct stat st; struct strbuf previous_name_buf = STRBUF_INIT, *previous_name; + int drop_cache_tree = 0; for (i = removed = extended = 0; i < entries; i++) { if (cache[i]->ce_flags & CE_REMOVE) @@@ -2248,8 -2241,6 +2242,8 @@@ warning(msg, ce->name); else return error(msg, ce->name); + + drop_cache_tree = 1; } if (ce_write_entry(&c, newfd, ce, previous_name) < 0) return -1; @@@ -2268,7 -2259,7 +2262,7 @@@ if (err) return -1; } - if (!strip_extensions && istate->cache_tree) { + if (!strip_extensions && !drop_cache_tree && istate->cache_tree) { struct strbuf sb = STRBUF_INIT; cache_tree_write(&sb, istate->cache_tree);