]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse-index: use WRITE_TREE_MISSING_OK
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 8 Sep 2021 01:42:29 +0000 (01:42 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Sep 2021 05:41:09 +0000 (22:41 -0700)
When updating the cache tree in convert_to_sparse(), the
WRITE_TREE_MISSING_OK flag indicates that trees might be computed that
do not already exist within the object database. This happens in cases
such as 'git add' creating new trees that it wants to store in
anticipation of a following 'git commit'. If this flag is not specified,
then it might trigger a promisor fetch or a failure due to the object
not existing locally.

Use WRITE_TREE_MISSING_OK during convert_to_sparse() to avoid these
possible reasons for the cache_tree_update() to fail.

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 d9b076959532b44fe3c5a3f9dad367aae55e3a87..880c5f723385054c760b7ca5acbf44727c03894c 100644 (file)
@@ -181,8 +181,11 @@ int convert_to_sparse(struct index_state *istate)
        /*
         * Silently return if there is a problem with the cache tree update,
         * which might just be due to a conflict state in some entry.
+        *
+        * This might create new tree objects, so be sure to use
+        * WRITE_TREE_MISSING_OK.
         */
-       if (cache_tree_update(istate, 0))
+       if (cache_tree_update(istate, WRITE_TREE_MISSING_OK))
                return 0;
 
        remove_fsmonitor(istate);