summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Stefan Beller <sbeller@google.com>2018-05-14 18:04:25 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-05-16 09:48:32 +0900
commitb2aa84c789a032c60b81d6ad68527e3a9076b99b (patch)
treefa87d4910690ad5e0c745e3a6c3e73a0f6a71952
parentPrepare for 2.15.2 (diff)
downloadtgif-b2aa84c789a032c60b81d6ad68527e3a9076b99b.tar.xz
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>
-rw-r--r--builtin/grep.c3
1 files changed, 2 insertions, 1 deletions
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];