diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-02-25 16:43:31 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-02-25 16:43:31 -0800 |
commit | 628c13cceed408526df39dbbd4a0d00bc4f34803 (patch) | |
tree | 64f99803d922d553df1effa6a1ddb7780da61c99 /builtin | |
parent | Merge branch 'ah/commit-graph-leakplug' (diff) | |
parent | grep: honor sparse-checkout on working tree searches (diff) | |
download | tgif-628c13cceed408526df39dbbd4a0d00bc4f34803.tar.xz |
Merge branch 'mt/grep-sparse-checkout'
"git grep" has been tweaked to be limited to the sparse checkout
paths.
* mt/grep-sparse-checkout:
grep: honor sparse-checkout on working tree searches
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, |