summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-02-16 14:39:00 -0800
committerJunio C Hamano <gitster@pobox.com>2011-02-16 14:39:00 -0800
commit9d8b831b36ca936f05e381e0f7f7a4b0d76114ee (patch)
treef2bd7913debe8d1690048b5d229e34e66c21b50b /builtin/grep.c
parentf577b92fe75643228674c0dcb2a4747587cf541d (diff)
downloadgit-9d8b831b36ca936f05e381e0f7f7a4b0d76114ee.tar.gz
grep --no-index: honor pathspecs correctly
Even though fill_directory() takes pathspec, the returned set of paths is not guaranteed to be free of paths outside the pathspec. Perhaps we would need to change that, but the current API is that the caller needs to further filter them. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index c3af8760cc..5afee2f3a4 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -626,6 +626,10 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec)
fill_directory(&dir, pathspec->raw);
for (i = 0; i < dir.nr; i++) {
+ const char *name = dir.entries[i]->name;
+ int namelen = strlen(name);
+ if (!match_pathspec_depth(pathspec, name, namelen, 0, NULL))
+ continue;
hit |= grep_file(opt, dir.entries[i]->name);
if (hit && opt->status_only)
break;