grep: do not unnecessarily query repo for "--"
[gitweb.git] / t / t7810-grep.sh
index de2405ccba29016d2b83e16482bcfcbe70429e46..2c1f7373e6bce9497a45894133757f58a3e084af 100755 (executable)
@@ -39,6 +39,10 @@ test_expect_success setup '
                echo "a+bc"
                echo "abc"
        } >ab &&
+       {
+               echo d &&
+               echo 0
+       } >d0 &&
        echo vvv >v &&
        echo ww w >w &&
        echo x x xx x >x &&
@@ -978,6 +982,21 @@ test_expect_success 'grep -e -- -- path' '
        test_cmp expected actual
 '
 
+test_expect_success 'grep --no-index pattern -- path' '
+       rm -fr non &&
+       mkdir -p non/git &&
+       (
+               GIT_CEILING_DIRECTORIES="$(pwd)/non" &&
+               export GIT_CEILING_DIRECTORIES &&
+               cd non/git &&
+               echo hello >hello &&
+               echo goodbye >goodbye &&
+               echo hello:hello >expect &&
+               git grep --no-index o -- hello >actual &&
+               test_cmp expect actual
+       )
+'
+
 cat >expected <<EOF
 hello.c:int main(int argc, const char **argv)
 hello.c:       printf("Hello world.\n");
@@ -1105,36 +1124,36 @@ test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =extended
 '
 
 test_expect_success 'grep -G -F -P -E pattern' '
-       >empty &&
-       test_must_fail git grep -G -F -P -E "a\x{2b}b\x{2a}c" ab >actual &&
-       test_cmp empty actual
+       echo "d0:d" >expected &&
+       git grep -G -F -P -E "[\d]" d0 >actual &&
+       test_cmp expected actual
 '
 
 test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =perl, =extended' '
-       >empty &&
-       test_must_fail git \
+       echo "d0:d" >expected &&
+       git \
                -c grep.patterntype=fixed \
                -c grep.patterntype=basic \
                -c grep.patterntype=perl \
                -c grep.patterntype=extended \
-               grep "a\x{2b}b\x{2a}c" ab >actual &&
-       test_cmp empty actual
+               grep "[\d]" d0 >actual &&
+       test_cmp expected actual
 '
 
 test_expect_success LIBPCRE 'grep -G -F -E -P pattern' '
-       echo "ab:a+b*c" >expected &&
-       git grep -G -F -E -P "a\x{2b}b\x{2a}c" ab >actual &&
+       echo "d0:0" >expected &&
+       git grep -G -F -E -P "[\d]" d0 >actual &&
        test_cmp expected actual
 '
 
 test_expect_success LIBPCRE 'grep pattern with grep.patternType=fixed, =basic, =extended, =perl' '
-       echo "ab:a+b*c" >expected &&
+       echo "d0:0" >expected &&
        git \
                -c grep.patterntype=fixed \
                -c grep.patterntype=basic \
                -c grep.patterntype=extended \
                -c grep.patterntype=perl \
-               grep "a\x{2b}b\x{2a}c" ab >actual &&
+               grep "[\d]" d0 >actual &&
        test_cmp expected actual
 '