git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] grep: support --no-ext-grep to test builtin grep

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 27, 2008, 08:21 UTC
Message-ID
<1230366064-1306-2-git-send-email-pclouds@gmail.com>
In-Reply-To
<1230366064-1306-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 used by the next patch
 builtin-grep.c |    8 +++++++-
 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;
-- 
1.6.0.4.1116.g25b13
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 2 of 4 in “grep: grep cache entries if they are "assume unchanged"”
  1. 2/2 grep: grep cache entries if they are "assume unchanged"Nguyễn Thái Ngọc Duy, Dec 27, 2008
  2. 1/2 grep: support --no-ext-grep to test builtin grepNguyễn Thái Ngọc Duy, Dec 27, 2008
  3. Junio C HamanoDec 27, 2008
  4. Junio C HamanoDec 28, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.