Skip to content

Commit 6ac5aca

Browse files
committed
Merge branch 'sb/grep-die-on-unreadable-index'
Error behaviour of "git grep" when it cannot read the index was inconsistent with other commands that uses the index, which has been corrected to error out early. * sb/grep-die-on-unreadable-index: grep: handle corrupt index files early
2 parents f15a486 + b2aa84c commit 6ac5aca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/grep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
488488
strbuf_addstr(&name, repo->submodule_prefix);
489489
}
490490

491-
repo_read_index(repo);
491+
if (repo_read_index(repo) < 0)
492+
die("index file corrupt");
492493

493494
for (nr = 0; nr < repo->index->cache_nr; nr++) {
494495
const struct cache_entry *ce = repo->index->cache[nr];

0 commit comments

Comments
 (0)