diff options
Diffstat (limited to 'builtin-grep.c')
-rw-r--r-- | builtin-grep.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/builtin-grep.c b/builtin-grep.c index 3c97c2c4d5..bebf15cd6f 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -404,7 +404,12 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached) continue; if (!pathspec_matches(paths, ce->name)) continue; - if (cached) { + /* + * If CE_VALID is on, we assume worktree file and its cache entry + * are identical, even if worktree file has been modified, so use + * cache version instead + */ + if (cached || (ce->ce_flags & CE_VALID)) { if (ce_stage(ce)) continue; hit |= grep_sha1(opt, ce->sha1, ce->name, 0); |