[PATCH 14/27] rm: ensure full index
- From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Mar 16, 2021, 21:17 UTC
- Message-ID
- <d6816560b32f020d6c38f5e9ad36be532685279c.1615929436.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.906.git.1615929435.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>
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> --- builtin/rm.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/builtin/rm.c b/builtin/rm.c index 4858631e0f02..99125ccb8424 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -293,6 +293,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) seen = xcalloc(pathspec.nr, 1); + ensure_full_index(&the_index); for (i = 0; i < active_nr; i++) { const struct cache_entry *ce = active_cache[i]; if (!ce_path_match(&the_index, ce, &pathspec, seen))
-- gitgitgadget