]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse-index: silently return when cache tree fails
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 8 Sep 2021 01:42:28 +0000 (01:42 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Sep 2021 05:41:09 +0000 (22:41 -0700)
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 <dstolee@microsoft.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sparse-index.c

index cd6e0d5f40814ca2a424e00f75cdabddce5f1c9f..d9b076959532b44fe3c5a3f9dad367aae55e3a87 100644 (file)
@@ -178,10 +178,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);