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>
Nguyễn Thái Ngọc Duy committed
Dec 27, 2008 at 15:21 UTC
e70b9a8bd2e25ced75cff2a2c26aed3f983425f8
1 file changed
+7
-1
builtin-grep.c
+7
-1
@@ -20,6 +20,8 @@
20
#endif
21
#endif
22
23
+static int builtin_grep;
24
+
25
/*
26
* git grep pathspecs are somewhat different from diff-tree pathspecs;
27
* pathname wildcards are allowed.
@@ -389,7 +391,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
391
* we grep through the checked-out files. It tends to
392
* be a lot more optimized
393
*/
392
- if (!cached) {
394
+ if (!cached && !builtin_grep) {
395
hit = external_grep(opt, paths, cached);
396
if (hit >= 0)
397
return hit;
@@ -545,6 +547,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
547
cached = 1;
548
continue;
549
}
550
+ if (!strcmp("--no-ext-grep", arg)) {
551
+ builtin_grep = 1;
552
+ continue;
553
+ }
554
if (!strcmp("-a", arg) ||
555
!strcmp("--text", arg)) {
556
opt.binary = GREP_BINARY_TEXT;