summaryrefslogtreecommitdiff
path: root/builtin-grep.c
diff options
context:
space:
mode:
authorRaphael Zimmerer <killekulla@rdrz.de>2008-10-01 16:11:15 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2008-10-01 16:14:54 (GMT)
commit83caecca2f0805d440099d19011fdedc2b3467a5 (patch)
treefd5ba5878c5058991a7e9e3bde78a8908221e500 /builtin-grep.c
parent5e22e21769454857e00bc55be1f2eef8d873ba72 (diff)
downloadgit-83caecca2f0805d440099d19011fdedc2b3467a5.zip
git-83caecca2f0805d440099d19011fdedc2b3467a5.tar.gz
git-83caecca2f0805d440099d19011fdedc2b3467a5.tar.bz2
git grep: Add "-z/--null" option as in GNU's grep.
Here's a trivial patch that adds "-z" and "--null" options to "git grep". It was discussed on the mailing-list that git's "-z" convention should be used instead of GNU grep's "-Z". So things like 'git grep -l -z "$FOO" | xargs -0 sed -i "s/$FOO/$BOO/"' do work now. Signed-off-by: Raphael Zimmerer <killekulla@rdrz.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'builtin-grep.c')
-rw-r--r--builtin-grep.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/builtin-grep.c b/builtin-grep.c
index 3a51662..624f86e 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -295,6 +295,9 @@ 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->null_following_name)
+ /* in GNU grep git's "-z" translates to "-Z" */
+ push_arg("-Z");
if (opt->count)
push_arg("-c");
if (opt->post_context || opt->pre_context) {
@@ -599,6 +602,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
opt.unmatch_name_only = 1;
continue;
}
+ if (!strcmp("-z", arg) ||
+ !strcmp("--null", arg)) {
+ opt.null_following_name = 1;
+ continue;
+ }
if (!strcmp("-c", arg) ||
!strcmp("--count", arg)) {
opt.count = 1;