grep: ensure full index
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>
Derrick Stolee committed
Apr 1, 2021 at 01:49 UTC
46eb6e31ef01684ec2dc64f690a63446022940e5
1 file changed
+2
builtin/grep.c
+2
@@ -504,6 +504,8 @@ static int grep_cache(struct grep_opt *opt,
504
if (repo_read_index(repo) < 0)
505
die(_("index file corrupt"));
506
507
+ /* TODO: audit for interaction with sparse-index. */
508
+ ensure_full_index(repo->index);
509
for (nr = 0; nr < repo->index->cache_nr; nr++) {
510
const struct cache_entry *ce = repo->index->cache[nr];
511