All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] grep: do not do external grep on skip-worktree entries
@ 2009-12-30 14:11 Nguyễn Thái Ngọc Duy
  2009-12-31  7:01 ` Junio C Hamano
  0 siblings, 1 reply; 60+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2009-12-30 14:11 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Skip-worktree entries are not on disk. There is no reason to call
external grep in such cases.

A trace message is also added to aid debugging external grep cases.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin-grep.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/builtin-grep.c b/builtin-grep.c
index d582232..d49c637 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -488,17 +488,34 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached,
 	read_cache();
 
 #if !NO_EXTERNAL_GREP
+	if (cached)
+		external_grep_allowed = 0;
+	if (external_grep_allowed) {
+		for (nr = 0; nr < active_nr; nr++) {
+			struct cache_entry *ce = active_cache[nr];
+			if (!S_ISREG(ce->ce_mode))
+				continue;
+			if (!pathspec_matches(paths, ce->name, opt->max_depth))
+				continue;
+			if (ce_skip_worktree(ce)) {
+				external_grep_allowed = 0;
+				break;
+			}
+		}
+	}
 	/*
 	 * Use the external "grep" command for the case where
 	 * we grep through the checked-out files. It tends to
 	 * be a lot more optimized
 	 */
-	if (!cached && external_grep_allowed) {
+	if (external_grep_allowed) {
 		hit = external_grep(opt, paths, cached);
 		if (hit >= 0)
 			return hit;
 		hit = 0;
 	}
+	else
+		trace_printf("grep: external grep not used\n");
 #endif
 
 	for (nr = 0; nr < active_nr; nr++) {
-- 
1.6.6.315.g1a406

^ permalink raw reply related	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2010-01-13 19:48 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-30 14:11 [PATCH] grep: do not do external grep on skip-worktree entries Nguyễn Thái Ngọc Duy
2009-12-31  7:01 ` Junio C Hamano
2009-12-31  7:09   ` Junio C Hamano
2010-01-02 11:50     ` Nguyen Thai Ngoc Duy
2010-01-02 18:44       ` Junio C Hamano
2010-01-02 19:15         ` Nguyen Thai Ngoc Duy
2010-01-02 19:45           ` Junio C Hamano
2010-01-03  2:35             ` Miles Bader
2010-01-03  2:47               ` Miles Bader
2010-01-03  3:08                 ` Miles Bader
2010-01-03 19:32                   ` Linus Torvalds
2010-01-03 20:49                     ` Junio C Hamano
2010-01-04  5:31                       ` Jeff King
2010-01-04  5:52                         ` Junio C Hamano
2010-01-04  6:44                           ` Jeff King
2010-01-04  7:08                             ` Junio C Hamano
2010-01-04  7:14                               ` Junio C Hamano
2010-01-04  7:29                                 ` Jeff King
2010-01-04  7:26                               ` Jeff King
2010-01-04  8:09                                 ` Jeff King
2010-01-04 16:01                                   ` Linus Torvalds
2010-01-04 15:54                             ` Linus Torvalds
2010-01-04 15:57                               ` Miles Bader
2010-01-04 16:03                                 ` Linus Torvalds
2010-01-11  6:39                                   ` Junio C Hamano
2010-01-11 15:43                                     ` Linus Torvalds
2010-01-11 15:59                                       ` Linus Torvalds
2010-01-11 16:22                                         ` Junio C Hamano
2010-01-11 16:24                                           ` Junio C Hamano
2010-01-11 16:33                                           ` Linus Torvalds
2010-01-12  8:29                                             ` Junio C Hamano
2010-01-12  8:31                                               ` [PATCH] grep: lookahead optimization can be used with -L option Junio C Hamano
2010-01-12  8:32                                               ` [PATCH] grep: -L should show empty files Junio C Hamano
2010-01-12 21:27                                                 ` Sverre Rabbelier
2010-01-13  6:56                                                   ` Junio C Hamano
2010-01-13 16:04                                                     ` Sverre Rabbelier
2010-01-13 19:48                                                       ` Junio C Hamano
2010-01-13  6:48                                               ` [PATCH 1/2] grep: rip out support for external grep Junio C Hamano
2010-01-13  8:29                                                 ` Jay Soffian
2010-01-13  8:59                                                   ` Junio C Hamano
2010-01-13 15:20                                                 ` Linus Torvalds
2010-01-13  6:51                                               ` [PATCH 2/2] grep: rip out pessimization to use fixmatch() Junio C Hamano
2010-01-12 16:21                                         ` [PATCH] grep: do not do external grep on skip-worktree entries Jeff King
2010-01-11 19:26                                     ` Fredrik Kuivinen
     [not found]                                     ` <4c8ef71001111119p253170f8q37bcd3708d894a62@mail.gmail.com>
2010-01-11 19:29                                       ` Linus Torvalds
2010-01-11 19:40                                         ` Fredrik Kuivinen
2010-01-11 20:07                                           ` Linus Torvalds
2010-01-11 21:07                                             ` Fredrik Kuivinen
2010-01-11 21:24                                               ` Linus Torvalds
2010-01-04 16:24                               ` Linus Torvalds
2010-01-04 10:14                           ` Nguyen Thai Ngoc Duy
2010-01-04  6:06                     ` Mike Hommey
2010-01-04  7:04                       ` Jeff King
2010-01-04 12:34             ` [PATCH 1/2] t7002: set test prerequisite "external-grep" if supported Nguyễn Thái Ngọc Duy
2010-01-07  2:37               ` Junio C Hamano
2010-01-07  4:29                 ` Junio C Hamano
2010-01-07 13:27                   ` Nguyen Thai Ngoc Duy
2010-01-07 14:04                     ` Johannes Sixt
2010-01-07 14:26                       ` Nguyen Thai Ngoc Duy
2010-01-04 12:34             ` [PATCH 2/2] t7002: add tests for skip-worktree fixes in commit a67e281 Nguyễn Thái Ngọc Duy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.