Thread (105 messages) 105 messages, 5 authors, 2021-04-13

[PATCH 24/27] resolve-undo: ensure full index

flat view
STALE2023d SUPERSEDED

From: Derrick Stolee via GitGitGadget <hidden>
Date: 2021-03-16 21:18:29
Subsystem: the rest · Maintainer: Linus Torvalds

Status: Superseded by v3 (posted 2021-04-12). [go to v3]

Revision v1 (3 revisions archived).

Revisions (3)
  1. v1 current
  2. v2 [diff against previous]
  3. v3 [diff against previous]
From: Derrick Stolee <redacted>

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 <redacted>
---
 resolve-undo.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/resolve-undo.c b/resolve-undo.c
index 236320f179cb..3ccd3f66f80f 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -172,6 +172,7 @@ void unmerge_marked_index(struct index_state *istate)
 	if (!istate->resolve_undo)
 		return;
 
+	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 +187,7 @@ void unmerge_index(struct index_state *istate, const struct pathspec *pathspec)
 	if (!istate->resolve_undo)
 		return;
 
+	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))
-- 
gitgitgadget
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help