Refactor cache_tree_update idiom from commit

We'll need to safely create or update the cache-tree data of the_index
from other places.  While at it, give it an argument that lets us
silence the messages produced by unmerged entries (which prevent it
from working).

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Thomas Rast
2011-12-06 18:43:37 +01:00
committed by Junio C Hamano
parent 4eb0346fb8
commit 996277c520
5 changed files with 21 additions and 11 deletions

View File

@ -862,10 +862,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
*/
discard_cache();
read_cache_from(index_file);
if (!active_cache_tree)
active_cache_tree = cache_tree();
if (cache_tree_update(active_cache_tree,
active_cache, active_nr, 0, 0) < 0) {
if (update_main_cache_tree(0)) {
error(_("Error building trees"));
return 0;
}