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

Re: [PATCH] RFC Allow case insensitive search flag with git-grep for fixed-strings

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 7, 2009, 00:00 UTC
Message-ID
<7vzl6ztd8s.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20091106101316.GA22549@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> On Fri, Nov 06, 2009 at 02:00:11AM -0800, Junio C Hamano wrote:
>
>> But I didn't try hard to find out what _else_ we are depending on.
>
> It is not really _us_ depending on it. It is "things the user wants to
> do that _we_ support, but that their grep might not." So I don't think
> there is much point in enumerating features. If their system grep
> doesn't handle options that they want to use, then it won't work for
> them. If they don't use them, then they will be fine.
>
> Though "-e" might be the exception, as I think we might use it
> unconditionally. But something like "-F -i" really depends on whether
> the user wants to use it.
Yes and no.

Even though we currently punt on a few platforms for simplicity and build with NO_EXTERNAL_GREP, we could check if the set of options given are within the feature set of what the platform's grep understands and choose to spawn "grep" unless some options that are unsupported are used, in which case we fall back to the internal one.

We could certainly do something like this if it turns out to be a problem. An invocation that does not use -F and -i together can still spawn external grep if that is faster.

You are correct about "-e". Our NO_EXTERNAL_GREP on SunOS cannot be avoided.

 builtin-grep.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-grep.c b/builtin-grep.c
index 1df25b0..2905f64 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -357,6 +357,9 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
 
 	if (opt->extended || (opt->relative && opt->prefix_length))
 		return -1;
+	if (NO_GREP_FIXED_IGNORE_CASE &&
+	    opt->fixed && (opt->regflags & REG_ICASE))
+		return -1;
 	len = nr = 0;
 	push_arg("grep");
 	if (opt->fixed)
Previous: Jeff KingNext: Nanako Shiraishi
Message 6 of 13 in “RFC Allow case insensitive search flag with git-grep for fixed-strings”
  1. RFC Allow case insensitive search flag with git-grep for fixed-stringsBrian Collins, Oct 30, 2009
  2. Jeff KingNov 6, 2009
  3. Brian CollinsNov 6, 2009
  4. Junio C HamanoNov 6, 2009
  5. Jeff KingNov 6, 2009
  6. Junio C HamanoNov 7, 2009
  7. Nanako ShiraishiNov 16, 2009
  8. Jeff KingNov 16, 2009
  9. Brian CollinsNov 16, 2009
  10. Brandon CaseyNov 16, 2009
  11. Junio C HamanoNov 16, 2009
  12. Junio C HamanoNov 17, 2009
  13. Jeff KingNov 17, 2009

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.