resolve-undo: ensure full index

Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Apr 1, 2021 at 01:49 UTC dc26b23ebc30adcb4aa54a5eccf2e47793984fa2
1 file changed +4
resolve-undo.c
+4
@@ -172,6 +172,8 @@ void unmerge_marked_index(struct index_state *istate)
172 if (!istate->resolve_undo)
173 return;
174
175 + /* TODO: audit for interaction with sparse-index. */
176 + ensure_full_index(istate);
177 for (i = 0; i < istate->cache_nr; i++) {
178 const struct cache_entry *ce = istate->cache[i];
179 if (ce->ce_flags & CE_MATCHED)
@@ -186,6 +188,8 @@ void unmerge_index(struct index_state *istate, const struct pathspec *pathspec)
188 if (!istate->resolve_undo)
189 return;
190
191 + /* TODO: audit for interaction with sparse-index. */
192 + ensure_full_index(istate);
193 for (i = 0; i < istate->cache_nr; i++) {
194 const struct cache_entry *ce = istate->cache[i];
195 if (!ce_path_match(istate, ce, pathspec, NULL))