summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-07-28 18:25:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-07-28 18:25:51 (GMT)
commitc12c71fabb3598a480111a31c151bc787cdced30 (patch)
tree29841719001633fa12b8324ff3b8bbd57fc95cec /builtin/grep.c
parent4966b58f3e1f295e3fb22560006b1db717b56f37 (diff)
parentb8e47d1acfa299299d1120241bdc6164867d1289 (diff)
downloadgit-c12c71fabb3598a480111a31c151bc787cdced30.zip
git-c12c71fabb3598a480111a31c151bc787cdced30.tar.gz
git-c12c71fabb3598a480111a31c151bc787cdced30.tar.bz2
Merge branch 'nd/ita-cleanup' into maint
Git does not know what the contents in the index should be for a path added with "git add -N" yet, so "git grep --cached" should not show hits (or show lack of hits, with -L) in such a path, but that logic does not apply to "git grep", i.e. searching in the working tree files. But we did so by mistake, which has been corrected. * nd/ita-cleanup: grep: fix grepping for "intent to add" files t7810-grep.sh: fix a whitespace inconsistency t7810-grep.sh: fix duplicated test name
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 462e607..ae73831 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -386,7 +386,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
for (nr = 0; nr < active_nr; nr++) {
const struct cache_entry *ce = active_cache[nr];
- if (!S_ISREG(ce->ce_mode) || ce_intent_to_add(ce))
+ if (!S_ISREG(ce->ce_mode))
continue;
if (!ce_path_match(ce, pathspec, NULL))
continue;
@@ -396,7 +396,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
* cache version instead
*/
if (cached || (ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) {
- if (ce_stage(ce))
+ if (ce_stage(ce) || ce_intent_to_add(ce))
continue;
hit |= grep_sha1(opt, ce->sha1, ce->name, 0, ce->name);
}