From: J Smith <dark.panda@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH/RFC 2/2] grep: rename "grep.extendedRegexp" option to "grep.patternType"
Date: Tue, 31 Jul 2012 18:53:29 -0400 [thread overview]
Message-ID: <1343775209-56505-2-git-send-email-dark.panda@gmail.com> (raw)
In-Reply-To: <1343775209-56505-1-git-send-email-dark.panda@gmail.com>
With the addition of the "basic", "extended", "fixed", and "perl"
values for the "grep.extendedRegexp" option the name "grep.patternType"
better represents the option's functionality. "grep.extendedRegexp"
remains available as an alias to "grep.patternType" for the purposes of
backwards compatibility.
---
Documentation/config.txt | 5 ++-
Documentation/git-grep.txt | 5 ++-
builtin/grep.c | 4 ++-
t/t7810-grep.sh | 80 ++++++++++++++++++++++++++--------------------
4 files changed, 56 insertions(+), 38 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 67d9f24..9644bba 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1210,13 +1210,16 @@ gitweb.snapshot::
grep.lineNumber::
If set to true, enable '-n' option by default.
-grep.extendedRegexp::
+grep.patternType::
Sets the default matching behavior. This option can be set to a
boolean value or one of 'basic', 'extended', 'fixed', or 'perl'
which will enable the '--basic-regexp', '--extended-regexp',
'--fixed-strings' or '--perl-regexp' options accordingly. The value
of 'true' is equivalent to 'extended'.
+grep.extendedRegexp::
+ Alias for grep.patternType.
+
gpg.program::
Use this custom program instead of "gpg" found on $PATH when
making or verifying a PGP signature. The program must support the
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 100328f..d51cc19 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -42,13 +42,16 @@ CONFIGURATION
grep.lineNumber::
If set to true, enable '-n' option by default.
-grep.extendedRegexp::
+grep.patternType::
Sets the default matching behavior. This option can be set to a
boolean value or one of 'basic', 'extended', 'fixed', or 'perl'
which will enable the '--basic-regexp', '--extended-regexp',
'--fixed-strings' or '--perl-regexp' options accordingly. The value
of 'true' is equivalent to 'extended'.
+grep.extendedRegexp::
+ Alias for grep.patternType.
+
OPTIONS
-------
diff --git a/builtin/grep.c b/builtin/grep.c
index 249fc7d..a8c1c32 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -317,7 +317,9 @@ static int grep_config(const char *var, const char *value, void *cb)
if (userdiff_config(var, value) < 0)
return -1;
- if (!strcmp(var, "grep.extendedregexp")) {
+ if (!strcmp(var, "grep.patterntype") ||
+ /* for backwards compatibility */
+ !strcmp(var, "grep.extendedregexp")) {
grep_pattern_type_options(parse_pattern_type_arg(var, value), opt);
return 0;
}
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index c21cd61..6bfe368 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -239,32 +239,32 @@ do
git grep --max-depth 0 -n -e vvv $H -- t . >actual &&
test_cmp expected actual
'
- test_expect_success "grep $L with grep.extendedRegexp=false" '
+ test_expect_success "grep $L with grep.patternType=false" '
echo "ab:a+bc" >expected &&
- git -c grep.extendedRegexp=false grep "a+b*c" ab >actual &&
+ git -c grep.patterntype=false grep "a+b*c" ab >actual &&
test_cmp expected actual
'
- test_expect_success "grep $L with grep.extendedRegexp=true" '
+ test_expect_success "grep $L with grep.patternType=true" '
echo "ab:abc" >expected &&
- git -c grep.extendedRegexp=true grep "a+b*c" ab >actual &&
+ git -c grep.patterntype=true grep "a+b*c" ab >actual &&
test_cmp expected actual
'
- test_expect_success "grep $L with grep.extendedRegexp=extended" '
+ test_expect_success "grep $L with grep.patternType=extended" '
echo "ab:abc" >expected &&
- git -c grep.extendedregexp=extended grep "a+b*c" ab >actual &&
+ git -c grep.patterntype=extended grep "a+b*c" ab >actual &&
test_cmp expected actual
'
- test_expect_success "grep $L with grep.extendedRegexp=fixed" '
+ test_expect_success "grep $L with grep.patternType=fixed" '
echo "ab:abc" >expected &&
- git -c grep.extendedregexp=fixed grep "ab" ab >actual &&
+ git -c grep.patterntype=fixed grep "ab" ab >actual &&
test_cmp expected actual
'
- test_expect_success "grep $L with a valid regexp and grep.extendedRegexp=fixed " '
- test_must_fail git -c grep.extendedregexp=fixed grep "a*" ab
+ test_expect_success "grep $L with a valid regexp and grep.patternType=fixed " '
+ test_must_fail git -c grep.patterntype=fixed grep "a*" ab
'
test_expect_success "grep $L with grep.extendedRegexp=basic" '
@@ -748,91 +748,91 @@ test_expect_success LIBPCRE 'grep -P pattern' '
test_cmp expected actual
'
-test_expect_success 'grep pattern with grep.extendedRegexp=true' '
+test_expect_success 'grep pattern with grep.patternType=true' '
>empty &&
- test_must_fail git -c grep.extendedregexp=true \
+ test_must_fail git -c grep.patterntype=true \
grep "\p{Ps}.*?\p{Pe}" hello.c >actual &&
test_cmp empty actual
'
-test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=true' '
- git -c grep.extendedregexp=true \
+test_expect_success LIBPCRE 'grep -P pattern with grep.patternType=true' '
+ git -c grep.patterntype=true \
grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
test_cmp expected actual
'
-test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=basic' '
- git -c grep.extendedregexp=basic \
+test_expect_success LIBPCRE 'grep -P pattern with grep.patternType=basic' '
+ git -c grep.patterntype=basic \
grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
test_cmp expected actual
'
-test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=extended' '
+test_expect_success LIBPCRE 'grep -P pattern with grep.patternType=extended' '
git -c grep.extendedregexp=extended \
grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
test_cmp expected actual
'
-test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=fixed' '
- git -c grep.extendedregexp=fixed \
+test_expect_success LIBPCRE 'grep -P pattern with grep.patternType=fixed' '
+ git -c grep.patterntype=fixed \
grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
test_cmp expected actual
'
-test_expect_success LIBPCRE 'grep pattern with grep.extendedRegexp=perl' '
- git -c grep.extendedregexp=perl \
+test_expect_success LIBPCRE 'grep pattern with grep.patternType=perl' '
+ git -c grep.patterntype=perl \
grep "\p{Ps}.*?\p{Pe}" hello.c >actual &&
test_cmp expected actual
'
-test_expect_success 'grep -E pattern with grep.extendedRegexp=perl' '
- test_must_fail git -c grep.extendedregexp=perl \
+test_expect_success 'grep -E pattern with grep.patternType=perl' '
+ test_must_fail git -c grep.patterntype=perl \
grep -E "\p{Ps}.*?\p{Pe}" hello.c
'
-test_expect_success 'grep -G pattern with grep.extendedRegexp=perl' '
- test_must_fail git -c grep.extendedregexp=perl \
+test_expect_success 'grep -G pattern with grep.patternType=perl' '
+ test_must_fail git -c grep.patterntype=perl \
grep -G "\p{Ps}.*?\p{Pe}" hello.c
'
-test_expect_success 'grep pattern with grep.extendedRegexp=fixed' '
+test_expect_success 'grep pattern with grep.patternType=fixed' '
>empty &&
- test_must_fail git -c grep.extendedregexp=fixed \
+ test_must_fail git -c grep.patterntype=fixed \
grep ".*" ab >actual &&
test_cmp empty actual
'
-test_expect_success 'grep -E pattern with grep.extendedRegexp=basic' '
+test_expect_success 'grep -E pattern with grep.patternType=basic' '
{
echo "ab:a+b*c"
echo "ab:a+bc"
echo "ab:abc"
} >expected &&
- git -c grep.extendedregexp=basic \
+ git -c grep.patterntype=basic \
grep -E ".?" ab >actual &&
test_cmp expected actual
'
-test_expect_success 'grep -E pattern with grep.extendedRegexp=fixed' '
+test_expect_success 'grep -E pattern with grep.patternType=fixed' '
{
echo "ab:a+b*c"
echo "ab:a+bc"
echo "ab:abc"
} >expected &&
- git -c grep.extendedregexp=fixed \
+ git -c grep.patterntype=fixed \
grep -E ".?" ab >actual &&
test_cmp expected actual
'
-test_expect_success 'grep -G pattern with grep.extendedRegexp=fixed' '
+test_expect_success 'grep -G pattern with grep.patternType=fixed' '
>empty &&
- test_must_fail git -c grep.extendedregexp=fixed \
+ test_must_fail git -c grep.patterntype=fixed \
grep -G ".?" ab >actual &&
test_cmp empty actual
'
-test_expect_success 'grep with grep.extendedRegexp=nonsense properly dies' '
- test_must_fail git -c grep.extendedregexp=nonsense \
+test_expect_success 'grep with grep.patternType=nonsense properly dies' '
+ test_must_fail git -c grep.patterntype=nonsense \
grep "\p{Ps}.*?\p{Pe}" hello.c
'
@@ -1015,4 +1015,14 @@ test_expect_success LIBPCRE 'grep -P "^ "' '
test_cmp expected actual
'
+test_expect_success "grep with grep.extendedRegexp=true for backwards compatibility" '
+ {
+ echo "ab:a+b*c"
+ echo "ab:a+bc"
+ echo "ab:abc"
+ } >expected &&
+ git -c grep.extendedregexp=true grep "a?" ab >actual &&
+ test_cmp expected actual
+'
+
test_done
--
1.7.11.3
next prev parent reply other threads:[~2012-07-31 22:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-31 22:53 [PATCH/RFC 1/2] grep: add "basic", "extended", "fixed", and "perl" to grep.extendedRegexp J Smith
2012-07-31 22:53 ` J Smith [this message]
2012-07-31 23:22 ` [PATCH/RFC 2/2] grep: rename "grep.extendedRegexp" option to "grep.patternType" Junio C Hamano
2012-08-01 3:38 ` J Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343775209-56505-2-git-send-email-dark.panda@gmail.com \
--to=dark.panda@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).