summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-05-01 19:39:21 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-05-01 19:40:17 (GMT)
commitdf0e7aa8644eef5ebc018bf838739e25f3494b6c (patch)
tree0e68520d1223088f31b99d77773b032021973bd2
parente0eb889f8e6597120527b0312874ff4c8448108e (diff)
downloadgit-df0e7aa8644eef5ebc018bf838739e25f3494b6c.zip
git-df0e7aa8644eef5ebc018bf838739e25f3494b6c.tar.gz
git-df0e7aa8644eef5ebc018bf838739e25f3494b6c.tar.bz2
builtin-grep: support '-l' option.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--builtin-grep.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/builtin-grep.c b/builtin-grep.c
index 653b65e..c3e6701 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -81,6 +81,7 @@ struct grep_opt {
regex_t regexp;
unsigned linenum:1;
unsigned invert:1;
+ unsigned name_only:1;
int regflags;
unsigned pre_context;
unsigned post_context;
@@ -139,6 +140,10 @@ static int grep_buffer(struct grep_opt *opt, const char *name,
if (opt->invert)
hit = !hit;
if (hit) {
+ if (opt->name_only) {
+ printf("%s\n", name);
+ return 1;
+ }
/* Hit at this line. If we haven't shown the
* pre-context lines, we would need to show them.
*/
@@ -406,6 +411,11 @@ int cmd_grep(int argc, const char **argv, char **envp)
*/
continue;
}
+ if (!strcmp("-l", arg) ||
+ !strcmp("--files-with-matches", arg)) {
+ opt.name_only = 1;
+ continue;
+ }
if (!strcmp("-A", arg) ||
!strcmp("-B", arg) ||
!strcmp("-C", arg)) {