summaryrefslogtreecommitdiff
path: root/builtin-grep.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2008-12-27 08:21:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-12-27 22:30:41 (GMT)
commite70b9a8bd2e25ced75cff2a2c26aed3f983425f8 (patch)
tree658abac2291fad92db51276ed09c7aeff2d2712f /builtin-grep.c
parent8104ebfe8276657ee803cca7eb8665a78cf3ef83 (diff)
downloadgit-e70b9a8bd2e25ced75cff2a2c26aed3f983425f8.zip
git-e70b9a8bd2e25ced75cff2a2c26aed3f983425f8.tar.gz
git-e70b9a8bd2e25ced75cff2a2c26aed3f983425f8.tar.bz2
grep: support --no-ext-grep to test builtin grep
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-grep.c')
-rw-r--r--builtin-grep.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/builtin-grep.c b/builtin-grep.c
index 624f86e..3c97c2c 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -20,6 +20,8 @@
#endif
#endif
+static int builtin_grep;
+
/*
* git grep pathspecs are somewhat different from diff-tree pathspecs;
* pathname wildcards are allowed.
@@ -389,7 +391,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
* we grep through the checked-out files. It tends to
* be a lot more optimized
*/
- if (!cached) {
+ if (!cached && !builtin_grep) {
hit = external_grep(opt, paths, cached);
if (hit >= 0)
return hit;
@@ -545,6 +547,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
cached = 1;
continue;
}
+ if (!strcmp("--no-ext-grep", arg)) {
+ builtin_grep = 1;
+ continue;
+ }
if (!strcmp("-a", arg) ||
!strcmp("--text", arg)) {
opt.binary = GREP_BINARY_TEXT;