Code

correct a few doubled-word nits in comments and documentation
[git.git] / t / t7810-grep.sh
index 81263b78516cbe2949ad7e426a5e44af188cccdd..d9ad633310a19a9ebbc2e5024875278d4631129e 100755 (executable)
@@ -47,6 +47,13 @@ test_expect_success setup '
        echo vvv >t/v &&
        mkdir t/a &&
        echo vvv >t/a/v &&
+       {
+               echo "line without leading space1"
+               echo " line with leading space1"
+               echo " line with leading space2"
+               echo " line with leading space3"
+               echo "line without leading space2"
+       } >space &&
        git add . &&
        test_tick &&
        git commit -m initial
@@ -245,6 +252,28 @@ do
        '
 done
 
+cat >expected <<EOF
+file
+EOF
+test_expect_success 'grep -l -C' '
+       git grep -l -C1 foo >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<EOF
+file:5
+EOF
+test_expect_success 'grep -l -C' '
+       git grep -c -C1 foo >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'grep -L -C' '
+       git ls-files >expected &&
+       git grep -L -C1 nonexistent_string >actual &&
+       test_cmp expected actual
+'
+
 cat >expected <<EOF
 file:foo mmap bar_mmap
 EOF
@@ -523,6 +552,20 @@ test_expect_success 'grep -W' '
        test_cmp expected actual
 '
 
+cat >expected <<EOF
+hello.c=       printf("Hello world.\n");
+hello.c:       return 0;
+hello.c-       /* char ?? */
+EOF
+
+test_expect_success 'grep -W with userdiff' '
+       test_when_finished "rm -f .gitattributes" &&
+       git config diff.custom.xfuncname "(printf.*|})$" &&
+       echo "hello.c diff=custom" >.gitattributes &&
+       git grep -W return >actual &&
+       test_cmp expected actual
+'
+
 test_expect_success 'grep from a subdirectory to search wider area (1)' '
        mkdir -p s &&
        (
@@ -857,4 +900,20 @@ test_expect_success 'mimic ack-grep --group' '
        test_cmp expected actual
 '
 
+cat >expected <<EOF
+space: line with leading space1
+space: line with leading space2
+space: line with leading space3
+EOF
+
+test_expect_success LIBPCRE 'grep -E "^ "' '
+       git grep -E "^ " space >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success LIBPCRE 'grep -P "^ "' '
+       git grep -P "^ " space >actual &&
+       test_cmp expected actual
+'
+
 test_done