]> asedeno.scripts.mit.edu Git - git.git/blobdiff - t/t7002-grep.sh
Merge branch 'tr/receive-pack-aliased-update-fix' into js/maint-receive-pack-symref-alias
[git.git] / t / t7002-grep.sh
index 6baa4461f704a39807cee861071f075f09da03da..af63d6ec6dfdf34b7a8ab4c19547d1d84cc184f2 100755 (executable)
@@ -8,18 +8,6 @@ test_description='git grep various.
 
 . ./test-lib.sh
 
-test_expect_success 'Check for external grep support' '
-       case "$(git grep -h 2>&1|grep ext-grep)" in
-       *"(default)"*)
-               test_set_prereq EXTGREP
-               true;;
-       *"(ignored by this build)"*)
-               true;;
-       *)
-               false;;
-       esac
-'
-
 cat >hello.c <<EOF
 #include <stdio.h>
 int main(int argc, const char **argv)
@@ -303,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.
@@ -314,8 +310,8 @@ test_expect_success 'grep -C1, hunk mark between files' '
        test_cmp expected actual
 '
 
-test_expect_success 'grep -C1 --no-ext-grep, hunk mark between files' '
-       git grep -C1 --no-ext-grep "^[yz]" >actual &&
+test_expect_success 'grep -C1 hunk mark between files' '
+       git grep -C1 "^[yz]" >actual &&
        test_cmp expected actual
 '
 
@@ -379,7 +375,7 @@ test_expect_success 'log --grep --author implicitly uses all-match' '
 test_expect_success 'grep with CE_VALID file' '
        git update-index --assume-unchanged t/t &&
        rm t/t &&
-       test "$(git grep --no-ext-grep test)" = "t/t:test" &&
+       test "$(git grep test)" = "t/t:test" &&
        git update-index --no-assume-unchanged t/t &&
        git checkout t/t
 '
@@ -446,16 +442,37 @@ test_expect_success 'grep -Fi' '
        test_cmp expected actual
 '
 
-test_expect_success EXTGREP 'external grep is called' '
-       GIT_TRACE=2 git grep foo >/dev/null 2>actual &&
-       grep "trace: grep:.*foo" actual >/dev/null
+test_expect_success 'setup double-dash tests' '
+cat >double-dash <<EOF &&
+--
+->
+other
+EOF
+git add double-dash
+'
+
+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
 '
 
-test_expect_success EXTGREP 'no external grep when skip-worktree entries exist' '
-       git update-index --skip-worktree file &&
-       GIT_TRACE=2 git grep foo >/dev/null 2>actual &&
-       ! grep "trace: grep:" actual >/dev/null &&
-       git update-index --no-skip-worktree file
+cat >expected <<EOF
+double-dash:--
+EOF
+test_expect_success 'grep -e -- -- path' '
+       git grep -e -- -- double-dash >actual &&
+       test_cmp expected actual
 '
 
 test_done