cache-tree: clean up cache_tree_update()
Make the method safer by allocating a cache_tree member for the given index_state if it is not already present. This is preferrable to a BUG() statement or returning with an error because future callers will want to populate an empty cache-tree using this method. Callers can also remove their conditional allocations of cache_tree. Also drop local variables that can be found directly from the 'istate' parameter. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
a4b6d202ca
commit
fb0882648e
@ -679,9 +679,6 @@ static int do_recursive_merge(struct repository *r,
|
||||
|
||||
static struct object_id *get_cache_tree_oid(struct index_state *istate)
|
||||
{
|
||||
if (!istate->cache_tree)
|
||||
istate->cache_tree = cache_tree();
|
||||
|
||||
if (!cache_tree_fully_valid(istate->cache_tree))
|
||||
if (cache_tree_update(istate, 0)) {
|
||||
error(_("unable to update cache tree"));
|
||||
|
||||
Reference in New Issue
Block a user