grep: handle corrupt index files early
Any other caller of 'repo_read_index' dies upon a negative return of it, so grep should, too. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3013dff866
commit
b2aa84c789
@ -480,7 +480,8 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
|
|||||||
strbuf_addstr(&name, repo->submodule_prefix);
|
strbuf_addstr(&name, repo->submodule_prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
repo_read_index(repo);
|
if (repo_read_index(repo) < 0)
|
||||||
|
die("index file corrupt");
|
||||||
|
|
||||||
for (nr = 0; nr < repo->index->cache_nr; nr++) {
|
for (nr = 0; nr < repo->index->cache_nr; nr++) {
|
||||||
const struct cache_entry *ce = repo->index->cache[nr];
|
const struct cache_entry *ce = repo->index->cache[nr];
|
||||||
|
Loading…
Reference in New Issue
Block a user