summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-30 12:51:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-30 12:51:26 (GMT)
commit6ac5acae2d93f49f169d9b10dd9fcbce3fd874e2 (patch)
tree7e34be3530a42546d012609d214a80394bb1a25e /builtin/grep.c
parentf15a486ca1dd67757cb6a3c0545dc2c6ef992bc3 (diff)
parentb2aa84c789a032c60b81d6ad68527e3a9076b99b (diff)
downloadgit-6ac5acae2d93f49f169d9b10dd9fcbce3fd874e2.zip
git-6ac5acae2d93f49f169d9b10dd9fcbce3fd874e2.tar.gz
git-6ac5acae2d93f49f169d9b10dd9fcbce3fd874e2.tar.bz2
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
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 6e7bc76..69f0743 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -488,7 +488,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];