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

index 4858631e0f02c5e52f3cd715712d6e569e751d03..5559a0b453a3566d85f6a550332ecd9ee8ebea88 100644 (file)
@@ -293,6 +293,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 
        seen = xcalloc(pathspec.nr, 1);
 
+       /* TODO: audit for interaction with sparse-index. */
+       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))