Merge branch 'maint-1.6.6' into maint
[gitweb.git] / t / t7002-grep.sh
index 7eceb086bee2f0b5c59341256b506775c21941e7..0b583cbfc15ae09c030c0d4e82635f244ffc5293 100755 (executable)
@@ -291,6 +291,14 @@ y:y yy
 z:zzz
 EOF
 
+test_expect_success 'grep -q, silently report matches' '
+       >empty &&
+       git grep -q mmap >actual &&
+       test_cmp empty actual &&
+       test_must_fail git grep -q qfwfq >actual &&
+       test_cmp empty actual
+'
+
 # Create 1024 file names that sort between "y" and "z" to make sure
 # the two files are handled by different calls to an external grep.
 # This depends on MAXARGS in builtin-grep.c being 1024 or less.
@@ -426,56 +434,37 @@ test_expect_success 'grep -Fi' '
        test_cmp expected actual
 '
 
-test_expect_success 'outside of git repository' '
-       rm -fr non &&
-       mkdir -p non/git/sub &&
-       echo hello >non/git/file1 &&
-       echo world >non/git/sub/file2 &&
-       echo ".*o*" >non/git/.gitignore &&
-       {
-               echo file1:hello &&
-               echo sub/file2:world
-       } >non/expect.full &&
-       echo file2:world >non/expect.sub
-       (
-               GIT_CEILING_DIRECTORIES="$(pwd)/non/git" &&
-               export GIT_CEILING_DIRECTORIES &&
-               cd non/git &&
-               test_must_fail git grep o &&
-               git grep --no-index o >../actual.full &&
-               test_cmp ../expect.full ../actual.full
-               cd sub &&
-               test_must_fail git grep o &&
-               git grep --no-index o >../../actual.sub &&
-               test_cmp ../../expect.sub ../../actual.sub
-       )
+test_expect_success 'setup double-dash tests' '
+cat >double-dash <<EOF &&
+--
+->
+other
+EOF
+git add double-dash
 '
 
-test_expect_success 'inside git repository but with --no-index' '
-       rm -fr is &&
-       mkdir -p is/git/sub &&
-       echo hello >is/git/file1 &&
-       echo world >is/git/sub/file2 &&
-       echo ".*o*" >is/git/.gitignore &&
-       {
-               echo file1:hello &&
-               echo sub/file2:world
-       } >is/expect.full &&
-       : >is/expect.empty &&
-       echo file2:world >is/expect.sub
-       (
-               cd is/git &&
-               git init &&
-               test_must_fail git grep o >../actual.full &&
-               test_cmp ../expect.empty ../actual.full &&
-               git grep --no-index o >../actual.full &&
-               test_cmp ../expect.full ../actual.full &&
-               cd sub &&
-               test_must_fail git grep o >../../actual.sub &&
-               test_cmp ../../expect.empty ../../actual.sub &&
-               git grep --no-index o >../../actual.sub &&
-               test_cmp ../../expect.sub ../../actual.sub
-       )
+cat >expected <<EOF
+double-dash:->
+EOF
+test_expect_success 'grep -- pattern' '
+       git grep -- "->" >actual &&
+       test_cmp expected actual
+'
+test_expect_success 'grep -- pattern -- pathspec' '
+       git grep -- "->" -- double-dash >actual &&
+       test_cmp expected actual
+'
+test_expect_success 'grep -e pattern -- path' '
+       git grep -e "->" -- double-dash >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<EOF
+double-dash:--
+EOF
+test_expect_success 'grep -e -- -- path' '
+       git grep -e -- -- double-dash >actual &&
+       test_cmp expected actual
 '
 
 test_done