Skip to content

Commit 8a96b9d

Browse files
derrickstoleegitster
authored andcommitted
sparse-index: use WRITE_TREE_MISSING_OK
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 <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5dc1675 commit 8a96b9d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sparse-index.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,11 @@ int convert_to_sparse(struct index_state *istate)
181181
/*
182182
* Silently return if there is a problem with the cache tree update,
183183
* which might just be due to a conflict state in some entry.
184+
*
185+
* This might create new tree objects, so be sure to use
186+
* WRITE_TREE_MISSING_OK.
184187
*/
185-
if (cache_tree_update(istate, 0))
188+
if (cache_tree_update(istate, WRITE_TREE_MISSING_OK))
186189
return 0;
187190

188191
remove_fsmonitor(istate);

0 commit comments

Comments
 (0)