Skip to content

Commit

Permalink
sparse-index: silently return when cache tree fails
Browse files Browse the repository at this point in the history
If cache_tree_update() returns a non-zero value, then it could not
create the cache tree likely due to a merge conflict. If we remove our
dependence on the cache tree within convert_to_sparse(), then we could
still recover from this scenario and have a sparse index. Since we are
already returning early, let's return silently to avoid making it seem
like we failed to write the index at all.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Jun 23, 2021
1 parent bf3f351 commit d99e695
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sparse-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ int convert_to_sparse(struct index_state *istate)

/* Clear and recompute the cache-tree */
cache_tree_free(&istate->cache_tree);
if (cache_tree_update(istate, 0)) {
warning(_("unable to update cache-tree, staying full"));
return -1;
}
/*
* Silently return if there is a problem with the cache tree update,
* which might just be due to a conflict state in some entry.
*/
if (cache_tree_update(istate, 0))
return 0;

remove_fsmonitor(istate);

Expand Down

0 comments on commit d99e695

Please sign in to comment.