{"thread":{"id":"23800","subject":"[PATCH 0/7] grep: better support for binary files","startedAt":"2010-05-13T20:33:21Z","lastAt":"2010-05-16T17:45:39Z","messageCount":10,"participants":["René Scharfe","Dmitry Potapov"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"141605","messageId":"4BEC6211.2000309@lsrfire.ath.cx","threadId":"23800","inReplyTo":null,"subject":"[PATCH 0/7] grep: better support for binary files","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-13T20:33:21Z","receivedAt":"2010-05-13T20:33:21Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"This series improves support of git grep for binary files.  It tries to\npick the low hanging fruits; at the end you can search _in_ files that\ncontain NUL characters, but you can't search _for_ NULs, yet.\n\n[PATCH 1/7] grep: add test script for binary file handling\n\n\tThis patch adds a simple test script documenting what git grep\n\tcan do with binary files.\n\n[PATCH 2/7] grep: refactor handling of binary mode options\n[PATCH 3/7] grep: --count over binary\n\n\tThese two makes git grep handle counting in binary files like\n\tGNU grep does.\n\n[PATCH 4/7] grep: use memmem() for fixed string search\n[PATCH 5/7] grep: continue case insensitive fixed string search after NUL chars\n\n\tThese two patches make git grep -F work on binary files.\n\n[PATCH 6/7] grep: add regmatch(), a wrapper for REG_STARTEND handling\n[PATCH 7/7] grep: use regmatch() for line matching\n\n\tThe final patches make git grep work on binary files if the\n\tplatform's regexec() supports the flag REG_STARTEND.  Our own\n\tversion in compat/ doesn't, unfortunately.\n\n\n grep.c                 |   70 ++++++++++++++++++++++++++++-------------------\n t/t7008-grep-binary.sh |   54 +++++++++++++++++++++++++++++++++++++\n 2 files changed, 96 insertions(+), 28 deletions(-)\n"},{"id":"141606","messageId":"4BEC6273.7070603@lsrfire.ath.cx","threadId":"23800","inReplyTo":"4BEC6211.2000309@lsrfire.ath.cx","subject":"[PATCH 1/7] grep: add test script for binary file handling","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-13T20:34:59Z","receivedAt":"2010-05-13T20:34:59Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n t/t7008-grep-binary.sh |   30 ++++++++++++++++++++++++++++++\n 1 files changed, 30 insertions(+), 0 deletions(-)\n create mode 100755 t/t7008-grep-binary.sh\n\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nnew file mode 100755\nindex 0000000..f9fd5e6\n--- /dev/null\n+++ b/t/t7008-grep-binary.sh\n@@ -0,0 +1,30 @@\n+#!/bin/sh\n+\n+test_description='git grep in binary files'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' \"\n+\tprintf 'binary\\000file\\n' >a &&\n+\tgit add a &&\n+\tgit commit -m.\n+\"\n+\n+test_expect_success 'git grep ina a' '\n+\techo Binary file a matches >expect &&\n+\tgit grep ina a >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'git grep -ah ina a' '\n+\tgit grep -ah ina a >actual &&\n+\ttest_cmp a actual\n+'\n+\n+test_expect_success 'git grep -I ina a' '\n+\t: >expect &&\n+\ttest_must_fail git grep -I ina a >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_done\n-- \n1.7.1\n"},{"id":"141607","messageId":"4BEC62BC.6060701@lsrfire.ath.cx","threadId":"23800","inReplyTo":"4BEC6211.2000309@lsrfire.ath.cx","subject":"[PATCH 2/7] grep: refactor handling of binary mode options","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-13T20:36:12Z","receivedAt":"2010-05-13T20:36:12Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Turn the switch inside-out and add labels for each possible value\nof ->binary.  This makes the code easier to read and avoids calling\nbuffer_is_binary() if the option -a was given.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n grep.c |   20 +++++++++++---------\n 1 files changed, 11 insertions(+), 9 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 543b1d5..2a8e879 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -800,17 +800,19 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,\n \t\topt->show_hunk_mark = 1;\n \topt->last_shown = 0;\n \n-\tif (buffer_is_binary(buf, size)) {\n-\t\tswitch (opt->binary) {\n-\t\tcase GREP_BINARY_DEFAULT:\n+\tswitch (opt->binary) {\n+\tcase GREP_BINARY_DEFAULT:\n+\t\tif (buffer_is_binary(buf, size))\n \t\t\tbinary_match_only = 1;\n-\t\t\tbreak;\n-\t\tcase GREP_BINARY_NOMATCH:\n+\t\tbreak;\n+\tcase GREP_BINARY_NOMATCH:\n+\t\tif (buffer_is_binary(buf, size))\n \t\t\treturn 0; /* Assume unmatch */\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tbreak;\n-\t\t}\n+\t\tbreak;\n+\tcase GREP_BINARY_TEXT:\n+\t\tbreak;\n+\tdefault:\n+\t\tdie(\"bug: unknown binary handling mode\");\n \t}\n \n \tmemset(&xecfg, 0, sizeof(xecfg));\n-- \n1.7.1\n"},{"id":"141608","messageId":"4BEC62F6.9050602@lsrfire.ath.cx","threadId":"23800","inReplyTo":"4BEC6211.2000309@lsrfire.ath.cx","subject":"[PATCH 3/7] grep: --count over binary","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-13T20:37:10Z","receivedAt":"2010-05-13T20:37:10Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"The intent of showing the message \"Binary file xyz matches\" for\nbinary files is to avoid annoying users by potentially messing up\ntheir terminals by printing control characters.  In --count mode,\nthis precaution isn't necessary.\n\nDisplay counts of matches if -c/--count was specified, even if -a\nwas not given.  GNU grep does the same.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n grep.c                 |    2 +-\n t/t7008-grep-binary.sh |    6 ++++++\n 2 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 2a8e879..4b6c02e 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -802,7 +802,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,\n \n \tswitch (opt->binary) {\n \tcase GREP_BINARY_DEFAULT:\n-\t\tif (buffer_is_binary(buf, size))\n+\t\tif (!opt->count && buffer_is_binary(buf, size))\n \t\t\tbinary_match_only = 1;\n \t\tbreak;\n \tcase GREP_BINARY_NOMATCH:\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nindex f9fd5e6..5449dd9 100755\n--- a/t/t7008-grep-binary.sh\n+++ b/t/t7008-grep-binary.sh\n@@ -27,4 +27,10 @@ test_expect_success 'git grep -I ina a' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'git grep -c ina a' '\n+\techo a:1 >expect &&\n+\tgit grep -c ina a >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n1.7.1\n"},{"id":"141609","messageId":"4BEC6338.9080300@lsrfire.ath.cx","threadId":"23800","inReplyTo":"4BEC6211.2000309@lsrfire.ath.cx","subject":"[PATCH 4/7] grep: use memmem() for fixed string search","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-13T20:38:16Z","receivedAt":"2010-05-13T20:38:16Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Allow searching beyond NUL characters by using memmem() instead of\nstrstr().\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n grep.c                 |   16 +++++++++-------\n t/t7008-grep-binary.sh |    4 ++++\n 2 files changed, 13 insertions(+), 7 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 4b6c02e..4633b63 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -329,14 +329,15 @@ static void show_name(struct grep_opt *opt, const char *name)\n \topt->output(opt, opt->null_following_name ? \"\\0\" : \"\\n\", 1);\n }\n \n-\n-static int fixmatch(const char *pattern, char *line, int ignore_case, regmatch_t *match)\n+static int fixmatch(const char *pattern, char *line, char *eol,\n+\t\t    int ignore_case, regmatch_t *match)\n {\n \tchar *hit;\n+\n \tif (ignore_case)\n \t\thit = strcasestr(line, pattern);\n \telse\n-\t\thit = strstr(line, pattern);\n+\t\thit = memmem(line, eol - line, pattern, strlen(pattern));\n \n \tif (!hit) {\n \t\tmatch->rm_so = match->rm_eo = -1;\n@@ -399,7 +400,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,\n \n  again:\n \tif (p->fixed)\n-\t\thit = !fixmatch(p->pattern, bol, p->ignore_case, pmatch);\n+\t\thit = !fixmatch(p->pattern, bol, eol, p->ignore_case, pmatch);\n \telse\n \t\thit = !regexec(&p->regexp, bol, 1, pmatch, eflags);\n \n@@ -725,9 +726,10 @@ static int look_ahead(struct grep_opt *opt,\n \t\tint hit;\n \t\tregmatch_t m;\n \n-\t\tif (p->fixed)\n-\t\t\thit = !fixmatch(p->pattern, bol, p->ignore_case, &m);\n-\t\telse {\n+\t\tif (p->fixed) {\n+\t\t\thit = !fixmatch(p->pattern, bol, bol + *left_p,\n+\t\t\t\t\tp->ignore_case, &m);\n+\t\t} else {\n #ifdef REG_STARTEND\n \t\t\tm.rm_so = 0;\n \t\t\tm.rm_eo = *left_p;\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nindex 5449dd9..ad97720 100755\n--- a/t/t7008-grep-binary.sh\n+++ b/t/t7008-grep-binary.sh\n@@ -33,4 +33,8 @@ test_expect_success 'git grep -c ina a' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'git grep -F ile a' '\n+\tgit grep -F ile a\n+'\n+\n test_done\n-- \n1.7.1\n"},{"id":"141610","messageId":"4BEC6385.8000106@lsrfire.ath.cx","threadId":"23800","inReplyTo":"4BEC6211.2000309@lsrfire.ath.cx","subject":"[PATCH 5/7] grep: continue case insensitive fixed string search after NUL chars","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-13T20:39:33Z","receivedAt":"2010-05-13T20:39:33Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Functions for C strings, like strcasestr(), can't see beyond NUL\ncharacters.  Check if there is such an obstacle on the line and try\nagain behind it.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n grep.c                 |   12 +++++++++---\n t/t7008-grep-binary.sh |    4 ++++\n 2 files changed, 13 insertions(+), 3 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 4633b63..20a02a2 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -334,9 +334,15 @@ static int fixmatch(const char *pattern, char *line, char *eol,\n {\n \tchar *hit;\n \n-\tif (ignore_case)\n-\t\thit = strcasestr(line, pattern);\n-\telse\n+\tif (ignore_case) {\n+\t\tchar *s = line;\n+\t\tdo {\n+\t\t\thit = strcasestr(s, pattern);\n+\t\t\tif (hit)\n+\t\t\t\tbreak;\n+\t\t\ts += strlen(s) + 1;\n+\t\t} while (s < eol);\n+\t} else\n \t\thit = memmem(line, eol - line, pattern, strlen(pattern));\n \n \tif (!hit) {\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nindex ad97720..1143903 100755\n--- a/t/t7008-grep-binary.sh\n+++ b/t/t7008-grep-binary.sh\n@@ -37,4 +37,8 @@ test_expect_success 'git grep -F ile a' '\n \tgit grep -F ile a\n '\n \n+test_expect_success 'git grep -Fi iLE a' '\n+\tgit grep -Fi iLE a\n+'\n+\n test_done\n-- \n1.7.1\n"},{"id":"141611","messageId":"4BEC63C0.7080207@lsrfire.ath.cx","threadId":"23800","inReplyTo":"4BEC6211.2000309@lsrfire.ath.cx","subject":"[PATCH 6/7] grep: add regmatch(), a wrapper for REG_STARTEND handling","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-13T20:40:32Z","receivedAt":"2010-05-13T20:40:32Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Refactor REG_STARTEND handling into a new helper, regmatch().\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n grep.c |   22 +++++++++++++---------\n 1 files changed, 13 insertions(+), 9 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 31c0e38..5be72cf 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -359,6 +359,17 @@ static int fixmatch(const char *pattern, char *line, char *eol,\n \t}\n }\n \n+static int regmatch(const regex_t *preg, char *line, char *eol,\n+\t\t    regmatch_t *match, int eflags)\n+{\n+#ifdef REG_STARTEND\n+\tmatch->rm_so = 0;\n+\tmatch->rm_eo = eol - line;\n+\teflags |= REG_STARTEND;\n+#endif\n+\treturn regexec(preg, line, 1, match, eflags);\n+}\n+\n static int strip_timestamp(char *bol, char **eol_p)\n {\n \tchar *eol = *eol_p;\n@@ -738,15 +749,8 @@ static int look_ahead(struct grep_opt *opt,\n \t\tif (p->fixed) {\n \t\t\thit = !fixmatch(p->pattern, bol, bol + *left_p,\n \t\t\t\t\tp->ignore_case, &m);\n-\t\t} else {\n-#ifdef REG_STARTEND\n-\t\t\tm.rm_so = 0;\n-\t\t\tm.rm_eo = *left_p;\n-\t\t\thit = !regexec(&p->regexp, bol, 1, &m, REG_STARTEND);\n-#else\n-\t\t\thit = !regexec(&p->regexp, bol, 1, &m, 0);\n-#endif\n-\t\t}\n+\t\t} else\n+\t\t\thit = !regmatch(&p->regexp, bol, bol + *left_p, &m, 0);\n \t\tif (!hit || m.rm_so < 0 || m.rm_eo < 0)\n \t\t\tcontinue;\n \t\tif (earliest < 0 || m.rm_so < earliest)\n-- \n1.7.1\n"},{"id":"141612","messageId":"4BEC63EB.2060307@lsrfire.ath.cx","threadId":"23800","inReplyTo":"4BEC6211.2000309@lsrfire.ath.cx","subject":"[PATCH 7/7] grep: use regmatch() for line matching","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-13T20:41:15Z","receivedAt":"2010-05-13T20:41:15Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Use regmatch() in match_one_pattern(), allowing regex matching\nbeyond NUL characters if regexec() supports the flag REG_STARTEND.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n grep.c                 |    2 +-\n t/t7008-grep-binary.sh |   10 ++++++++++\n 2 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 5be72cf..9dd2471 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -422,7 +422,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,\n \tif (p->fixed)\n \t\thit = !fixmatch(p->pattern, bol, eol, p->ignore_case, pmatch);\n \telse\n-\t\thit = !regexec(&p->regexp, bol, 1, pmatch, eflags);\n+\t\thit = !regmatch(&p->regexp, bol, eol, pmatch, eflags);\n \n \tif (hit && p->word_regexp) {\n \t\tif ((pmatch[0].rm_so < 0) ||\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nindex 1143903..d8fde18 100755\n--- a/t/t7008-grep-binary.sh\n+++ b/t/t7008-grep-binary.sh\n@@ -41,4 +41,14 @@ test_expect_success 'git grep -Fi iLE a' '\n \tgit grep -Fi iLE a\n '\n \n+# This test actually passes on platforms where regexec() supports the\n+# flag REG_STARTEND.\n+test_expect_failure 'git grep ile a' '\n+\tgit grep ile a\n+'\n+\n+test_expect_failure 'git grep .fi a' '\n+\tgit grep .fi a\n+'\n+\n test_done\n-- \n1.7.1\n"},{"id":"141639","messageId":"20100514093424.GA6212@dpotapov.dyndns.org","threadId":"23800","inReplyTo":"4BEC62F6.9050602@lsrfire.ath.cx","subject":"Re: [PATCH 3/7] grep: --count over binary","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-05-14T09:34:24Z","receivedAt":"2010-05-14T09:34:24Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Thu, May 13, 2010 at 10:37:10PM +0200, René Scharfe wrote:\n> The intent of showing the message \"Binary file xyz matches\" for\n> binary files is to avoid annoying users by potentially messing up\n> their terminals by printing control characters.  In --count mode,\n> this precaution isn't necessary.\n> \n> Display counts of matches if -c/--count was specified, even if -a\n> was not given.  GNU grep does the same.\n\nIt is also not necessary with '-l' and '-L' options. (At least, if\nwe follow GNU grep).\n\n> --- a/grep.c\n> +++ b/grep.c\n> @@ -802,7 +802,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,\n>  \n>  \tswitch (opt->binary) {\n>  \tcase GREP_BINARY_DEFAULT:\n> -\t\tif (buffer_is_binary(buf, size))\n> +\t\tif (!opt->count && buffer_is_binary(buf, size))\n>  \t\t\tbinary_match_only = 1;\n\nSo, I believe it should be:\n\n\t\tif (!opt->count && !opt->name_only && !opt->unmatch_name_only &&\n\t\t\t\tbuffer_is_binary(buf, size))\n\n\nDmitry\n"},{"id":"141779","messageId":"4BF02F43.7020204@lsrfire.ath.cx","threadId":"23800","inReplyTo":"20100514093424.GA6212@dpotapov.dyndns.org","subject":"Re: [PATCH 3/7] grep: --count over binary","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2010-05-16T17:45:39Z","receivedAt":"2010-05-16T17:45:39Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 14.05.2010 11:34, schrieb Dmitry Potapov:\n> On Thu, May 13, 2010 at 10:37:10PM +0200, René Scharfe wrote:\n>> The intent of showing the message \"Binary file xyz matches\" for\n>> binary files is to avoid annoying users by potentially messing up\n>> their terminals by printing control characters.  In --count mode,\n>> this precaution isn't necessary.\n>>\n>> Display counts of matches if -c/--count was specified, even if -a\n>> was not given.  GNU grep does the same.\n> \n> It is also not necessary with '-l' and '-L' options. (At least, if\n> we follow GNU grep).\n\nGood point.  The same is true for -q, too.  ->unmatch_name_only (-L)\nand ->status_only (-q) are already handled correctly because they are\nchecked before binary_match_only.  We can do the same for ->name_only.\n\n-- >8 --\nSubject: grep: --name-only over binary\n\nAs with the option -c/--count, git grep with the option -l/--name-only\nshould work the same with binary files as with text files because\nthere is no danger of messing up the terminal with control characters\nfrom the contents of matching files.  GNU grep does the same.\n\nMove the check for ->name_only before the one for binary_match_only,\nthus making the latter irrelevant for git grep -l.  Also add a simple\ntest for each of -l, -L and -q.  The latter two options were already\nhandled before binary_match_only, so no code changes were needed to\nmake them pass.\n\nReported-by: Dmitry Potapov <dpotapov@gmail.com>\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n grep.c                 |    8 ++++----\n t/t7008-grep-binary.sh |   18 ++++++++++++++++++\n 2 files changed, 22 insertions(+), 4 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 2b2f70e..f292e25 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -885,6 +885,10 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,\n \t\t\tcount++;\n \t\t\tif (opt->status_only)\n \t\t\t\treturn 1;\n+\t\t\tif (opt->name_only) {\n+\t\t\t\tshow_name(opt, name);\n+\t\t\t\treturn 1;\n+\t\t\t}\n \t\t\tif (binary_match_only) {\n \t\t\t\topt->output(opt, \"Binary file \", 12);\n \t\t\t\toutput_color(opt, name, strlen(name),\n@@ -892,10 +896,6 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,\n \t\t\t\topt->output(opt, \" matches\\n\", 9);\n \t\t\t\treturn 1;\n \t\t\t}\n-\t\t\tif (opt->name_only) {\n-\t\t\t\tshow_name(opt, name);\n-\t\t\t\treturn 1;\n-\t\t\t}\n \t\t\t/* Hit at this line.  If we haven't shown the\n \t\t\t * pre-context lines, we would need to show them.\n \t\t\t * When asked to do \"count\", this still show\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nindex d8fde18..4f5e74f 100755\n--- a/t/t7008-grep-binary.sh\n+++ b/t/t7008-grep-binary.sh\n@@ -33,6 +33,24 @@ test_expect_success 'git grep -c ina a' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'git grep -l ina a' '\n+\techo a >expect &&\n+\tgit grep -l ina a >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'git grep -L bar a' '\n+\techo a >expect &&\n+\tgit grep -L bar a >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'git grep -q ina a' '\n+\t: >expect &&\n+\tgit grep -q ina a >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'git grep -F ile a' '\n \tgit grep -F ile a\n '\n-- \n1.7.1\n"}]}