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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html