From: Stefan Beller Date: Tue, 15 May 2018 01:04:25 +0000 (-0700) Subject: grep: handle corrupt index files early X-Git-Tag: v2.18.0-rc0~11^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b2aa84c789a032c60b81d6ad68527e3a9076b99b;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin/grep.c b/builtin/grep.c index 5a6cfe6b45..567565b2d2 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -480,7 +480,8 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo, 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++) { const struct cache_entry *ce = repo->index->cache[nr];