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
@ -1726,8 +1726,6 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||
if (!ret) {
|
||||
if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
|
||||
cache_tree_verify(the_repository, &o->result);
|
||||
if (!o->result.cache_tree)
|
||||
o->result.cache_tree = cache_tree();
|
||||
if (!cache_tree_fully_valid(o->result.cache_tree))
|
||||
cache_tree_update(&o->result,
|
||||
WRITE_TREE_SILENT |
|
||||
|
Reference in New Issue
Block a user