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

Re: git grep -I bug

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 2, 2009, 17:54 UTC
Message-ID
<7vwsc8hgh4.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090202174257.GA8259@Ambelina.erc-wireless.uc.edu>
Jeremy O'Brien <obrien654j@gmail.com> writes:
Show 7 quoted lines
> I am running git version 1.6.1.2.309.g2ea3.
>
> When I use
>
> git grep -I "string_to_match"
>
> to ignore binary files in my grep, binary files are returned anyway.

One sanity check. What does 'git grep --cached -I "string_to_match"' do in that case?

If it works as expected but without --cached it doesn't, then I think the following patch will fix it.

-- >8 --
Subject: grep: pass -I (ignore binary) down to external grep
The external-grep codepath forgets to pass this option.  Fix it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-grep.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git c/builtin-grep.c w/builtin-grep.c
index bebf15c..c799fdd 100644
--- c/builtin-grep.c
+++ w/builtin-grep.c
@@ -297,6 +297,8 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
 		push_arg("-l");
 	if (opt->unmatch_name_only)
 		push_arg("-L");
+	if (opt->binary == GREP_BINARY_NOMATCH)
+		push_arg("-I");
 	if (opt->null_following_name)
 		/* in GNU grep git's "-z" translates to "-Z" */
 		push_arg("-Z");
Previous: Jeremy O'BrienNext: Jeremy O'Brien
Message 2 of 5 in “git grep -I bug”
  1. Jeremy O'BrienFeb 2, 2009
  2. Junio C HamanoFeb 2, 2009
  3. Jeremy O'BrienFeb 2, 2009
  4. Junio C HamanoFeb 3, 2009
  5. Jeremy O'BrienFeb 3, 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.