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>
Junio C Hamano committed
Feb 16, 2011 at 14:39 UTC
9d8b831b36ca936f05e381e0f7f7a4b0d76114ee
1 file changed
+4
builtin/grep.c
+4
@@ -626,6 +626,10 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec)
626
627
fill_directory(&dir, pathspec->raw);
628
for (i = 0; i < dir.nr; i++) {
629
+ const char *name = dir.entries[i]->name;
630
+ int namelen = strlen(name);
631
+ if (!match_pathspec_depth(pathspec, name, namelen, 0, NULL))
632
+ continue;
633
hit |= grep_file(opt, dir.entries[i]->name);
634
if (hit && opt->status_only)
635
break;