git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Whit Armstrong <armstrong.whit@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH 10/16] add NO_EXTERNAL_GREP build option
Date: Wed, 12 Mar 2008 17:39:16 -0400	[thread overview]
Message-ID: <20080312213916.GK26286@coredump.intra.peff.net> (raw)
In-Reply-To: <cover.1205356737.git.peff@peff.net>

Previously, we just chose whether to allow external grep
based on the __unix__ define. However, there are systems
which define this macro but which have an inferior group
(e.g., one that does not support all options used by t7002).
This allows users to accept the potential speed penalty to
get a more consistent grep experience (and to pass the
testsuite).

Signed-off-by: Jeff King <peff@peff.net>
---
This might have fallouts for msysgit (i.e., they need to define
NO_EXTERNAL_GREP instead of relying on __unix__ not being defined).

 Makefile       |    7 +++++++
 builtin-grep.c |    4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index e3eaa6a..8e80225 100644
--- a/Makefile
+++ b/Makefile
@@ -148,6 +148,9 @@ all::
 # is a simplified version of the merge sort used in glibc. This is
 # recommended if Git triggers O(n^2) behavior in your platform's qsort().
 #
+# Define NO_EXTERNAL_GREP if you don't want "git grep" to ever call
+# your external grep (e.g., if your system lacks grep, or if its grep is
+# not very featureful).
 
 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -467,6 +470,7 @@ ifeq ($(uname_O),Cygwin)
 	NO_STRCASESTR = YesPlease
 	NO_MEMMEM = YesPlease
 	NO_SYMLINK_HEAD = YesPlease
+	NO_EXTERNAL_GREP = YesPlease
 	NEEDS_LIBICONV = YesPlease
 	NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
 	NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
@@ -760,6 +764,9 @@ endif
 ifdef DIR_HAS_BSD_GROUP_SEMANTICS
 	COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
 endif
+ifdef NO_EXTERNAL_GREP
+	BASIC_CFLAGS += -DNO_EXTERNAL_GREP
+endif
 
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK=NoThanks
diff --git a/builtin-grep.c b/builtin-grep.c
index f4f4ecb..f215b28 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -153,7 +153,7 @@ static int grep_file(struct grep_opt *opt, const char *filename)
 	return i;
 }
 
-#ifdef __unix__
+#ifndef NO_EXTERNAL_GREP
 static int exec_grep(int argc, const char **argv)
 {
 	pid_t pid;
@@ -372,7 +372,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
 	int nr;
 	read_cache();
 
-#ifdef __unix__
+#ifndef NO_EXTERNAL_GREP
 	/*
 	 * Use the external "grep" command for the case where
 	 * we grep through the checked-out files. It tends to
-- 
1.5.4.4.543.g30fdd.dirty

  parent reply	other threads:[~2008-03-12 21:40 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1205356737.git.peff@peff.net>
2008-03-12 21:29 ` [PATCH 01/16] tr portability fixes Jeff King
2008-03-13  7:32   ` Johannes Sixt
2008-03-13 13:06     ` Jeff King
2008-03-12 21:30 ` [PATCH 02/16] t0050: perl portability fix Jeff King
2008-03-13  7:38   ` Johannes Sixt
2008-03-12 21:31 ` [PATCH 03/16] more tr portability test script fixes Jeff King
2008-03-13  8:28   ` Frank Lichtenheld
2008-03-13 13:09     ` Jeff King
2008-03-18 22:23   ` Alex Riesen
2008-03-18 22:24     ` [PATCH] Add test-tr: poor-man tr for the test suite Alex Riesen
2008-03-18 22:24       ` [PATCH] Use test-tr in " Alex Riesen
2008-03-18 22:44     ` [PATCH 03/16] more tr portability test script fixes Jeff King
2008-03-18 23:24       ` Alex Riesen
2008-03-19 21:40       ` Junio C Hamano
2008-03-19 22:56         ` Alex Riesen
2008-03-12 21:32 ` [PATCH 04/16] grep portability fix: don't use "-e" or "-q" Jeff King
2008-03-12 22:10   ` Junio C Hamano
2008-03-12 22:45     ` Junio C Hamano
2008-03-12 21:34 ` [PATCH 05/16] remove use of "tail -n 1" and "tail -1" Jeff King
2008-03-12 21:36 ` [PATCH 06/16] add test_cmp function for test scripts Jeff King
2008-03-12 22:12   ` Junio C Hamano
2008-03-13 12:08     ` Jeff King
2008-03-13 20:48       ` Junio C Hamano
2008-03-12 21:37 ` [PATCH 07/16] t4020: don't use grep -a Jeff King
2008-03-12 21:37 ` [PATCH 08/16] t4200: use cut instead of sed Jeff King
2008-03-13  4:52   ` Junio C Hamano
2008-03-13 12:59     ` Jeff King
2008-03-13 18:00       ` Junio C Hamano
2008-03-14 21:40         ` Jeff King
2008-03-12 21:38 ` [PATCH 09/16] t6000lib: tr portability fix Jeff King
2008-03-14 20:47   ` [PATCH] t/t6000lib.sh: tr portability fix fix Brandon Casey
2008-03-14 20:54     ` Jeff King
2008-03-14 21:00       ` Brandon Casey
2008-03-14 21:26       ` Brandon Casey
2008-03-14 21:45         ` Jeff King
2008-03-14 22:06           ` Brandon Casey
2008-03-12 21:39 ` Jeff King [this message]
2008-03-12 22:30   ` [PATCH 10/16] add NO_EXTERNAL_GREP build option Junio C Hamano
2008-03-13 12:10     ` Jeff King
2008-03-13  7:50   ` Johannes Sixt
2008-03-13 12:41     ` Jeff King
2008-03-13 13:59       ` Johannes Sixt
2008-03-13 14:04         ` Jeff King
2008-03-13 14:09           ` Johannes Sixt
2008-03-13  7:56   ` Junio C Hamano
2008-03-12 21:40 ` [PATCH 11/16] config: add --literal-match option Jeff King
2008-03-12 21:46   ` Jakub Narebski
2008-03-13 13:24     ` Jeff King
2008-03-12 22:34   ` Junio C Hamano
2008-03-13 12:42     ` Jeff King
2008-03-12 21:40 ` [PATCH 12/16] git-submodule: avoid sed input with no newline Jeff King
2008-03-12 22:41   ` Junio C Hamano
2008-03-13 12:46     ` Jeff King
2008-03-12 21:41 ` [PATCH 13/16] filter-branch: don't use xargs -0 Jeff King
2008-03-12 21:41 ` [PATCH 14/16] filter-branch: use $SHELL_PATH instead of 'sh' Jeff King
2008-03-12 21:42 ` [PATCH 15/16] t9112: add missing #!/bin/sh header Jeff King
2008-03-12 21:42 ` [PATCH 16/16] t7505: use SHELL_PATH in hook Jeff King
2008-03-13  7:11   ` Adam Piatyszek
2008-03-13 13:00     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080312213916.GK26286@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=armstrong.whit@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).