]> git.ipfire.org Git - thirdparty/git.git/commitdiff
resolve-undo: ensure full index
authorDerrick Stolee <dstolee@microsoft.com>
Thu, 1 Apr 2021 01:49:59 +0000 (01:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Apr 2021 20:47:45 +0000 (13:47 -0700)
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>
resolve-undo.c

index 236320f179cbf60a312f882ee57e1f843398e907..ee36ca58b135226c51b4d374be84a43613ba03c8 100644 (file)
@@ -172,6 +172,8 @@ void unmerge_marked_index(struct index_state *istate)
        if (!istate->resolve_undo)
                return;
 
+       /* TODO: audit for interaction with sparse-index. */
+       ensure_full_index(istate);
        for (i = 0; i < istate->cache_nr; i++) {
                const struct cache_entry *ce = istate->cache[i];
                if (ce->ce_flags & CE_MATCHED)
@@ -186,6 +188,8 @@ void unmerge_index(struct index_state *istate, const struct pathspec *pathspec)
        if (!istate->resolve_undo)
                return;
 
+       /* TODO: audit for interaction with sparse-index. */
+       ensure_full_index(istate);
        for (i = 0; i < istate->cache_nr; i++) {
                const struct cache_entry *ce = istate->cache[i];
                if (!ce_path_match(istate, ce, pathspec, NULL))