summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8f852ce)
raw | patch | inline | side by side (parent: 8f852ce)
author | Michał Kiedrowicz <michal.kiedrowicz@gmail.com> | |
Mon, 9 May 2011 21:52:08 +0000 (23:52 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 9 May 2011 23:29:55 +0000 (16:29 -0700) |
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>
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>
builtin/grep.c | patch | blob | history | |
t/t7810-grep.sh | patch | blob | history |
diff --git a/builtin/grep.c b/builtin/grep.c
index 6831975104b35aa1c94d251d525f7f11702a757b..8f2602653ee1e017c326a726aa485dd17abd03df 100644 (file)
--- a/builtin/grep.c
+++ b/builtin/grep.c
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
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index e845218f67a4d14160900884bb0b0d9c8785ba97..2a31eca5f257e674390bee1a93eb5a867262eff5 100755 (executable)
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
test_cmp expected actual
'
+test_expect_success LIBPCRE 'grep -P -F returns error' '
+ test_expect_code 128 git grep -P -F main
+'
+
+test_expect_success LIBPCRE 'grep -P -E returns error' '
+ test_expect_code 128 git grep -P -E main
+'
+
+test_expect_failure LIBPCRE 'grep -P -G returns error' '
+ test_expect_code 128 git grep -P -G main
+'
+
+test_expect_failure LIBPCRE 'grep -P -E -G returns error' '
+ test_expect_code 128 git grep -P -E -G main
+'
+
test_done