diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index e348e6bb32..4e91a253ac 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -506,6 +506,10 @@ static int grep_cache(struct grep_opt *opt, for (nr = 0; nr < repo->index->cache_nr; nr++) { const struct cache_entry *ce = repo->index->cache[nr]; + + if (!cached && ce_skip_worktree(ce)) + continue; + strbuf_setlen(&name, name_base_len); strbuf_addstr(&name, ce->name); @@ -518,8 +522,7 @@ static int grep_cache(struct grep_opt *opt, * cache entry are identical, even if worktree file has * been modified, so use cache version instead */ - if (cached || (ce->ce_flags & CE_VALID) || - ce_skip_worktree(ce)) { + if (cached || (ce->ce_flags & CE_VALID)) { if (ce_stage(ce) || ce_intent_to_add(ce)) continue; hit |= grep_oid(opt, &ce->oid, name.buf, |