Skip to content

Commit 5dc1675

Browse files
derrickstoleegitster
authored andcommitted
sparse-index: silently return when cache tree fails
If cache_tree_update() returns a non-zero value, then it could not create the cache tree. This is likely due to a path having a merge conflict. Since we are already returning early, let's return silently to avoid making it seem like we failed to write the index at all. 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. Signed-off-by: Derrick Stolee <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 72d84ea commit 5dc1675

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sparse-index.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,12 @@ int convert_to_sparse(struct index_state *istate)
178178

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

186188
remove_fsmonitor(istate);
187189

0 commit comments

Comments
 (0)