Skip to content

Commit e70b9a8

Browse files
pcloudsgitster
authored andcommitted
grep: support --no-ext-grep to test builtin grep
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8104ebf commit e70b9a8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

builtin-grep.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#endif
2121
#endif
2222

23+
static int builtin_grep;
24+
2325
/*
2426
* git grep pathspecs are somewhat different from diff-tree pathspecs;
2527
* pathname wildcards are allowed.
@@ -389,7 +391,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
389391
* we grep through the checked-out files. It tends to
390392
* be a lot more optimized
391393
*/
392-
if (!cached) {
394+
if (!cached && !builtin_grep) {
393395
hit = external_grep(opt, paths, cached);
394396
if (hit >= 0)
395397
return hit;
@@ -545,6 +547,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
545547
cached = 1;
546548
continue;
547549
}
550+
if (!strcmp("--no-ext-grep", arg)) {
551+
builtin_grep = 1;
552+
continue;
553+
}
548554
if (!strcmp("-a", arg) ||
549555
!strcmp("--text", arg)) {
550556
opt.binary = GREP_BINARY_TEXT;

0 commit comments

Comments
 (0)