]> git.ipfire.org Git - thirdparty/git.git/commitdiff
grep: ensure full index
authorDerrick Stolee <dstolee@microsoft.com>
Thu, 1 Apr 2021 01:49:48 +0000 (01:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Apr 2021 20:47:13 +0000 (13:47 -0700)
Before iterating over all cache entries, ensure that a sparse index is
expanded to a full one so we do not miss blobs to scan. Later, this can
integrate more carefully with sparse indexes with proper testing.

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/grep.c

index 4e91a253ac3b5fd0cdbd0436018c82fb45bde04c..c2d40414e97550296e6bd0d41175994105cef480 100644 (file)
@@ -504,6 +504,8 @@ static int grep_cache(struct grep_opt *opt,
        if (repo_read_index(repo) < 0)
                die(_("index file corrupt"));
 
+       /* TODO: audit for interaction with sparse-index. */
+       ensure_full_index(repo->index);
        for (nr = 0; nr < repo->index->cache_nr; nr++) {
                const struct cache_entry *ce = repo->index->cache[nr];