summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorMichał Kiedrowicz <michal.kiedrowicz@gmail.com>2011-05-09 21:52:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-09 23:29:55 (GMT)
commit258a6188496fe5131203905b6cd596af69312247 (patch)
treefee161aea408ef5664189db041cc89ae509b1353 /builtin
parent8f852ce613650b0cccf02adecbc18865d8e21fb6 (diff)
downloadgit-258a6188496fe5131203905b6cd596af69312247.zip
git-258a6188496fe5131203905b6cd596af69312247.tar.gz
git-258a6188496fe5131203905b6cd596af69312247.tar.bz2
git-grep: Bail out when -P is used with -F or -E
This patch makes git-grep die() when -P is used on command line together with -E/--extended-regexp or -F/--fixed-strings. This also makes it bail out when grep.extendedRegexp is enabled. But `git grep -G -P pattern` and `git grep -E -G -P pattern` still work because -G and -E set opts.regflags during parse_options() and there is no way to detect `-G` or `-E -G`. Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/grep.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 6831975..8f26026 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -925,9 +925,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
if (!opt.pattern_list)
die(_("no pattern given."));
+ if (opt.regflags != REG_NEWLINE && opt.pcre)
+ die(_("cannot mix --extended-regexp and --perl-regexp"));
if (!opt.fixed && opt.ignore_case)
opt.regflags |= REG_ICASE;
- if ((opt.regflags != REG_NEWLINE) && opt.fixed)
+ if ((opt.regflags != REG_NEWLINE || opt.pcre) && opt.fixed)
die(_("cannot mix --fixed-strings and regexp"));
#ifndef NO_PTHREADS