3 # Copyright (c) 2006 Junio C Hamano
6 test_description='git grep various.
13 int main(int argc, const char **argv)
15 printf("Hello world.\n");
21 test_expect_success setup '
25 echo foo_mmap bar mmap
26 echo foo mmap bar_mmap
27 echo foo_mmap bar mmap baz
51 echo "line without leading space1"
52 echo " line with leading space1"
53 echo " line with leading space2"
54 echo " line with leading space3"
55 echo "line without leading space2"
62 test_expect_success 'grep should not segfault with a bad input' '
63 test_must_fail git grep "("
69 HEAD) HC='HEAD:' L='HEAD' ;;
70 '') HC= L='in working tree' ;;
73 test_expect_success "grep -w $L" '
75 echo ${HC}file:1:foo mmap bar
76 echo ${HC}file:3:foo_mmap bar mmap
77 echo ${HC}file:4:foo mmap bar_mmap
78 echo ${HC}file:5:foo_mmap bar mmap baz
80 git -c grep.linenumber=false grep -n -w -e mmap $H >actual &&
81 test_cmp expected actual
84 test_expect_success "grep -w $L" '
86 echo ${HC}file:1:foo mmap bar
87 echo ${HC}file:3:foo_mmap bar mmap
88 echo ${HC}file:4:foo mmap bar_mmap
89 echo ${HC}file:5:foo_mmap bar mmap baz
91 git -c grep.linenumber=true grep -w -e mmap $H >actual &&
92 test_cmp expected actual
95 test_expect_success "grep -w $L" '
97 echo ${HC}file:foo mmap bar
98 echo ${HC}file:foo_mmap bar mmap
99 echo ${HC}file:foo mmap bar_mmap
100 echo ${HC}file:foo_mmap bar mmap baz
102 git -c grep.linenumber=true grep --no-line-number -w -e mmap $H >actual &&
103 test_cmp expected actual
106 test_expect_success "grep -w $L (w)" '
108 test_must_fail git grep -n -w -e "^w" >actual &&
109 test_cmp expected actual
112 test_expect_success "grep -w $L (x)" '
114 echo ${HC}x:1:x x xx x
116 git grep -n -w -e "x xx* x" $H >actual &&
117 test_cmp expected actual
120 test_expect_success "grep -w $L (y-1)" '
124 git grep -n -w -e "^y" $H >actual &&
125 test_cmp expected actual
128 test_expect_success "grep -w $L (y-2)" '
130 if git grep -n -w -e "^y y" $H >actual
132 echo should not have matched
136 test_cmp expected actual
140 test_expect_success "grep -w $L (z)" '
142 if git grep -n -w -e "^z" $H >actual
144 echo should not have matched
148 test_cmp expected actual
152 test_expect_success "grep $L (t-1)" '
153 echo "${HC}t/t:1:test" >expected &&
154 git grep -n -e test $H >actual &&
155 test_cmp expected actual
158 test_expect_success "grep $L (t-2)" '
159 echo "${HC}t:1:test" >expected &&
162 git grep -n -e test $H
164 test_cmp expected actual
167 test_expect_success "grep $L (t-3)" '
168 echo "${HC}t/t:1:test" >expected &&
171 git grep --full-name -n -e test $H
173 test_cmp expected actual
176 test_expect_success "grep -c $L (no /dev/null)" '
177 ! git grep -c test $H | grep /dev/null
180 test_expect_success "grep --max-depth -1 $L" '
182 echo ${HC}t/a/v:1:vvv
186 git grep --max-depth -1 -n -e vvv $H >actual &&
187 test_cmp expected actual
190 test_expect_success "grep --max-depth 0 $L" '
194 git grep --max-depth 0 -n -e vvv $H >actual &&
195 test_cmp expected actual
198 test_expect_success "grep --max-depth 0 -- '*' $L" '
200 echo ${HC}t/a/v:1:vvv
204 git grep --max-depth 0 -n -e vvv $H -- "*" >actual &&
205 test_cmp expected actual
208 test_expect_success "grep --max-depth 1 $L" '
213 git grep --max-depth 1 -n -e vvv $H >actual &&
214 test_cmp expected actual
217 test_expect_success "grep --max-depth 0 -- t $L" '
221 git grep --max-depth 0 -n -e vvv $H -- t >actual &&
222 test_cmp expected actual
225 test_expect_success "grep --max-depth 0 -- . t $L" '
230 git grep --max-depth 0 -n -e vvv $H -- . t >actual &&
231 test_cmp expected actual
234 test_expect_success "grep --max-depth 0 -- t . $L" '
239 git grep --max-depth 0 -n -e vvv $H -- t . >actual &&
240 test_cmp expected actual
242 test_expect_success "grep $L with grep.extendedRegexp=false" '
243 echo "ab:a+bc" >expected &&
244 git -c grep.extendedRegexp=false grep "a+b*c" ab >actual &&
245 test_cmp expected actual
248 test_expect_success "grep $L with grep.extendedRegexp=true" '
249 echo "ab:abc" >expected &&
250 git -c grep.extendedRegexp=true grep "a+b*c" ab >actual &&
251 test_cmp expected actual
254 test_expect_success "grep $L with grep.patterntype=basic" '
255 echo "ab:a+bc" >expected &&
256 git -c grep.patterntype=basic grep "a+b*c" ab >actual &&
257 test_cmp expected actual
260 test_expect_success "grep $L with grep.patterntype=extended" '
261 echo "ab:abc" >expected &&
262 git -c grep.patterntype=extended grep "a+b*c" ab >actual &&
263 test_cmp expected actual
266 test_expect_success "grep $L with grep.patterntype=fixed" '
267 echo "ab:a+b*c" >expected &&
268 git -c grep.patterntype=fixed grep "a+b*c" ab >actual &&
269 test_cmp expected actual
272 test_expect_success LIBPCRE "grep $L with grep.patterntype=perl" '
273 echo "ab:a+b*c" >expected &&
274 git -c grep.patterntype=perl grep "a\x{2b}b\x{2a}c" ab >actual &&
275 test_cmp expected actual
278 test_expect_success "grep $L with grep.patternType=default and grep.extendedRegexp=true" '
279 echo "ab:abc" >expected &&
281 -c grep.patternType=default \
282 -c grep.extendedRegexp=true \
283 grep "a+b*c" ab >actual &&
284 test_cmp expected actual
287 test_expect_success "grep $L with grep.extendedRegexp=true and grep.patternType=default" '
288 echo "ab:abc" >expected &&
290 -c grep.extendedRegexp=true \
291 -c grep.patternType=default \
292 grep "a+b*c" ab >actual &&
293 test_cmp expected actual
296 test_expect_success 'grep $L with grep.patternType=extended and grep.extendedRegexp=false' '
297 echo "ab:abc" >expected &&
299 -c grep.patternType=extended \
300 -c grep.extendedRegexp=false \
301 grep "a+b*c" ab >actual &&
302 test_cmp expected actual
305 test_expect_success 'grep $L with grep.patternType=basic and grep.extendedRegexp=true' '
306 echo "ab:a+bc" >expected &&
308 -c grep.patternType=basic \
309 -c grep.extendedRegexp=true \
310 grep "a+b*c" ab >actual &&
311 test_cmp expected actual
314 test_expect_success 'grep $L with grep.extendedRegexp=false and grep.patternType=extended' '
315 echo "ab:abc" >expected &&
317 -c grep.extendedRegexp=false \
318 -c grep.patternType=extended \
319 grep "a+b*c" ab >actual &&
320 test_cmp expected actual
323 test_expect_success 'grep $L with grep.extendedRegexp=true and grep.patternType=basic' '
324 echo "ab:a+bc" >expected &&
326 -c grep.extendedRegexp=true \
327 -c grep.patternType=basic \
328 grep "a+b*c" ab >actual &&
329 test_cmp expected actual
336 test_expect_success 'grep -l -C' '
337 git grep -l -C1 foo >actual &&
338 test_cmp expected actual
344 test_expect_success 'grep -l -C' '
345 git grep -c -C1 foo >actual &&
346 test_cmp expected actual
349 test_expect_success 'grep -L -C' '
350 git ls-files >expected &&
351 git grep -L -C1 nonexistent_string >actual &&
352 test_cmp expected actual
356 file:foo mmap bar_mmap
359 test_expect_success 'grep -e A --and -e B' '
360 git grep -e "foo mmap" --and -e bar_mmap >actual &&
361 test_cmp expected actual
365 file:foo_mmap bar mmap
366 file:foo_mmap bar mmap baz
370 test_expect_success 'grep ( -e A --or -e B ) --and -e B' '
371 git grep \( -e foo_ --or -e baz \) \
372 --and -e " mmap" >actual &&
373 test_cmp expected actual
380 test_expect_success 'grep -e A --and --not -e B' '
381 git grep -e "foo mmap" --and --not -e bar_mmap >actual &&
382 test_cmp expected actual
385 test_expect_success 'grep should ignore GREP_OPTIONS' '
386 GREP_OPTIONS=-v git grep " mmap bar\$" >actual &&
387 test_cmp expected actual
390 test_expect_success 'grep -f, non-existent file' '
391 test_must_fail git grep -f patterns
397 file:foo_mmap bar mmap
398 file:foo mmap bar_mmap
399 file:foo_mmap bar mmap baz
406 test_expect_success 'grep -f, one pattern' '
407 git grep -f pattern >actual &&
408 test_cmp expected actual
414 file:foo_mmap bar mmap
415 file:foo mmap bar_mmap
416 file:foo_mmap bar mmap baz
427 test_expect_success 'grep -f, multiple patterns' '
428 git grep -f patterns >actual &&
429 test_cmp expected actual
432 test_expect_success 'grep, multiple patterns' '
433 git grep "$(cat patterns)" >actual &&
434 test_cmp expected actual
440 file:foo_mmap bar mmap
441 file:foo mmap bar_mmap
442 file:foo_mmap bar mmap baz
456 test_expect_success 'grep -f, ignore empty lines' '
457 git grep -f patterns >actual &&
458 test_cmp expected actual
461 test_expect_success 'grep -f, ignore empty lines, read patterns from stdin' '
462 git grep -f - <patterns >actual &&
463 test_cmp expected actual
472 test_expect_success 'grep -q, silently report matches' '
474 git grep -q mmap >actual &&
475 test_cmp empty actual &&
476 test_must_fail git grep -q qfwfq >actual &&
477 test_cmp empty actual
480 # Create 1024 file names that sort between "y" and "z" to make sure
481 # the two files are handled by different calls to an external grep.
482 # This depends on MAXARGS in builtin-grep.c being 1024 or less.
483 c32="0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v"
484 test_expect_success 'grep -C1, hunk mark between files' '
485 for a in $c32; do for b in $c32; do : >y-$a$b; done; done &&
487 git grep -C1 "^[yz]" >actual &&
488 test_cmp expected actual
491 test_expect_success 'grep -C1 hunk mark between files' '
492 git grep -C1 "^[yz]" >actual &&
493 test_cmp expected actual
496 test_expect_success 'log grep setup' '
499 GIT_AUTHOR_NAME="With * Asterisk" \
500 GIT_AUTHOR_EMAIL="xyzzy@frotz.com" \
501 git commit -a -m "second" &&
505 git commit -a -m "third" &&
509 GIT_AUTHOR_NAME="Night Fall" \
510 GIT_AUTHOR_EMAIL="nitfol@frobozz.com" \
511 git commit -a -m "fourth"
514 test_expect_success 'log grep (1)' '
515 git log --author=author --pretty=tformat:%s >actual &&
516 ( echo third ; echo initial ) >expect &&
517 test_cmp expect actual
520 test_expect_success 'log grep (2)' '
521 git log --author=" * " -F --pretty=tformat:%s >actual &&
522 ( echo second ) >expect &&
523 test_cmp expect actual
526 test_expect_success 'log grep (3)' '
527 git log --author="^A U" --pretty=tformat:%s >actual &&
528 ( echo third ; echo initial ) >expect &&
529 test_cmp expect actual
532 test_expect_success 'log grep (4)' '
533 git log --author="frotz\.com>$" --pretty=tformat:%s >actual &&
534 ( echo second ) >expect &&
535 test_cmp expect actual
538 test_expect_success 'log grep (5)' '
539 git log --author=Thor -F --pretty=tformat:%s >actual &&
540 ( echo third ; echo initial ) >expect &&
541 test_cmp expect actual
544 test_expect_success 'log grep (6)' '
545 git log --author=-0700 --pretty=tformat:%s >actual &&
547 test_cmp expect actual
550 test_expect_success 'log --grep --author implicitly uses all-match' '
551 # grep matches initial and second but not third
552 # author matches only initial and third
553 git log --author="A U Thor" --grep=s --grep=l --format=%s >actual &&
554 echo initial >expect &&
555 test_cmp expect actual
558 test_expect_success 'log with multiple --author uses union' '
559 git log --author="Thor" --author="Aster" --format=%s >actual &&
561 echo third && echo second && echo initial
563 test_cmp expect actual
566 test_expect_success 'log with --grep and multiple --author uses all-match' '
567 git log --author="Thor" --author="Night" --grep=i --format=%s >actual &&
569 echo third && echo initial
571 test_cmp expect actual
574 test_expect_success 'log with --grep and multiple --author uses all-match' '
575 git log --author="Thor" --author="Night" --grep=q --format=%s >actual &&
577 test_cmp expect actual
580 test_expect_success 'grep with CE_VALID file' '
581 git update-index --assume-unchanged t/t &&
583 test "$(git grep test)" = "t/t:test" &&
584 git update-index --no-assume-unchanged t/t &&
589 hello.c=#include <stdio.h>
593 test_expect_success 'grep -p with userdiff' '
594 git config diff.custom.funcname "^#" &&
595 echo "hello.c diff=custom" >.gitattributes &&
596 git grep -p return >actual &&
597 test_cmp expected actual
601 hello.c=int main(int argc, const char **argv)
605 test_expect_success 'grep -p' '
606 rm -f .gitattributes &&
607 git grep -p return >actual &&
608 test_cmp expected actual
612 hello.c-#include <stdio.h>
613 hello.c=int main(int argc, const char **argv)
615 hello.c- printf("Hello world.\n");
619 test_expect_success 'grep -p -B5' '
620 git grep -p -B5 return >actual &&
621 test_cmp expected actual
625 hello.c=int main(int argc, const char **argv)
627 hello.c- printf("Hello world.\n");
629 hello.c- /* char ?? */
633 test_expect_success 'grep -W' '
634 git grep -W return >actual &&
635 test_cmp expected actual
639 hello.c= printf("Hello world.\n");
641 hello.c- /* char ?? */
644 test_expect_success 'grep -W with userdiff' '
645 test_when_finished "rm -f .gitattributes" &&
646 git config diff.custom.xfuncname "(printf.*|})$" &&
647 echo "hello.c diff=custom" >.gitattributes &&
648 git grep -W return >actual &&
649 test_cmp expected actual
652 test_expect_success 'grep from a subdirectory to search wider area (1)' '
655 cd s && git grep "x x x" ..
659 test_expect_success 'grep from a subdirectory to search wider area (2)' '
663 ( git grep xxyyzz .. >out ; echo $? >status )
665 test 1 = $(cat status)
670 hello.c:int main(int argc, const char **argv)
673 test_expect_success 'grep -Fi' '
674 git grep -Fi "CHAR *" >actual &&
675 test_cmp expected actual
678 test_expect_success 'outside of git repository' '
680 mkdir -p non/git/sub &&
681 echo hello >non/git/file1 &&
682 echo world >non/git/sub/file2 &&
686 } >non/expect.full &&
687 echo file2:world >non/expect.sub &&
689 GIT_CEILING_DIRECTORIES="$(pwd)/non/git" &&
690 export GIT_CEILING_DIRECTORIES &&
692 test_must_fail git grep o &&
693 git grep --no-index o >../actual.full &&
694 test_cmp ../expect.full ../actual.full
696 test_must_fail git grep o &&
697 git grep --no-index o >../../actual.sub &&
698 test_cmp ../../expect.sub ../../actual.sub
701 echo ".*o*" >non/git/.gitignore &&
703 GIT_CEILING_DIRECTORIES="$(pwd)/non/git" &&
704 export GIT_CEILING_DIRECTORIES &&
706 test_must_fail git grep o &&
707 git grep --no-index --exclude-standard o >../actual.full &&
708 test_cmp ../expect.full ../actual.full &&
711 echo ".gitignore:.*o*"
713 } >../expect.with.ignored &&
714 git grep --no-index --no-exclude o >../actual.full &&
715 test_cmp ../expect.with.ignored ../actual.full
719 test_expect_success 'inside git repository but with --no-index' '
721 mkdir -p is/git/sub &&
722 echo hello >is/git/file1 &&
723 echo world >is/git/sub/file2 &&
724 echo ".*o*" >is/git/.gitignore &&
728 } >is/expect.unignored &&
730 echo ".gitignore:.*o*" &&
731 cat is/expect.unignored
733 : >is/expect.empty &&
734 echo file2:world >is/expect.sub &&
738 test_must_fail git grep o >../actual.full &&
739 test_cmp ../expect.empty ../actual.full &&
741 git grep --untracked o >../actual.unignored &&
742 test_cmp ../expect.unignored ../actual.unignored &&
744 git grep --no-index o >../actual.full &&
745 test_cmp ../expect.full ../actual.full &&
747 git grep --no-index --exclude-standard o >../actual.unignored &&
748 test_cmp ../expect.unignored ../actual.unignored &&
751 test_must_fail git grep o >../../actual.sub &&
752 test_cmp ../../expect.empty ../../actual.sub &&
754 git grep --no-index o >../../actual.sub &&
755 test_cmp ../../expect.sub ../../actual.sub &&
757 git grep --untracked o >../../actual.sub &&
758 test_cmp ../../expect.sub ../../actual.sub
762 test_expect_success 'setup double-dash tests' '
763 cat >double-dash <<EOF &&
774 test_expect_success 'grep -- pattern' '
775 git grep -- "->" >actual &&
776 test_cmp expected actual
778 test_expect_success 'grep -- pattern -- pathspec' '
779 git grep -- "->" -- double-dash >actual &&
780 test_cmp expected actual
782 test_expect_success 'grep -e pattern -- path' '
783 git grep -e "->" -- double-dash >actual &&
784 test_cmp expected actual
790 test_expect_success 'grep -e -- -- path' '
791 git grep -e -- -- double-dash >actual &&
792 test_cmp expected actual
796 hello.c:int main(int argc, const char **argv)
797 hello.c: printf("Hello world.\n");
800 test_expect_success LIBPCRE 'grep --perl-regexp pattern' '
801 git grep --perl-regexp "\p{Ps}.*?\p{Pe}" hello.c >actual &&
802 test_cmp expected actual
805 test_expect_success LIBPCRE 'grep -P pattern' '
806 git grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
807 test_cmp expected actual
810 test_expect_success 'grep pattern with grep.extendedRegexp=true' '
812 test_must_fail git -c grep.extendedregexp=true \
813 grep "\p{Ps}.*?\p{Pe}" hello.c >actual &&
814 test_cmp empty actual
817 test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=true' '
818 git -c grep.extendedregexp=true \
819 grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
820 test_cmp expected actual
823 test_expect_success LIBPCRE 'grep -P -v pattern' '
828 git grep -P -v "abc" ab >actual &&
829 test_cmp expected actual
832 test_expect_success LIBPCRE 'grep -P -i pattern' '
833 cat >expected <<-EOF &&
834 hello.c: printf("Hello world.\n");
836 git grep -P -i "PRINTF\([^\d]+\)" hello.c >actual &&
837 test_cmp expected actual
840 test_expect_success LIBPCRE 'grep -P -w pattern' '
842 echo "hello_world:Hello world"
843 echo "hello_world:HeLLo world"
845 git grep -P -w "He((?i)ll)o" hello_world >actual &&
846 test_cmp expected actual
849 test_expect_success 'grep -G invalidpattern properly dies ' '
850 test_must_fail git grep -G "a["
853 test_expect_success 'grep invalidpattern properly dies with grep.patternType=basic' '
854 test_must_fail git -c grep.patterntype=basic grep "a["
857 test_expect_success 'grep -E invalidpattern properly dies ' '
858 test_must_fail git grep -E "a["
861 test_expect_success 'grep invalidpattern properly dies with grep.patternType=extended' '
862 test_must_fail git -c grep.patterntype=extended grep "a["
865 test_expect_success LIBPCRE 'grep -P invalidpattern properly dies ' '
866 test_must_fail git grep -P "a["
869 test_expect_success LIBPCRE 'grep invalidpattern properly dies with grep.patternType=perl' '
870 test_must_fail git -c grep.patterntype=perl grep "a["
873 test_expect_success 'grep -G -E -F pattern' '
874 echo "ab:a+b*c" >expected &&
875 git grep -G -E -F "a+b*c" ab >actual &&
876 test_cmp expected actual
879 test_expect_success 'grep pattern with grep.patternType=basic, =extended, =fixed' '
880 echo "ab:a+b*c" >expected &&
882 -c grep.patterntype=basic \
883 -c grep.patterntype=extended \
884 -c grep.patterntype=fixed \
885 grep "a+b*c" ab >actual &&
886 test_cmp expected actual
889 test_expect_success 'grep -E -F -G pattern' '
890 echo "ab:a+bc" >expected &&
891 git grep -E -F -G "a+b*c" ab >actual &&
892 test_cmp expected actual
895 test_expect_success 'grep pattern with grep.patternType=extended, =fixed, =basic' '
896 echo "ab:a+bc" >expected &&
898 -c grep.patterntype=extended \
899 -c grep.patterntype=fixed \
900 -c grep.patterntype=basic \
901 grep "a+b*c" ab >actual &&
902 test_cmp expected actual
905 test_expect_success 'grep -F -G -E pattern' '
906 echo "ab:abc" >expected &&
907 git grep -F -G -E "a+b*c" ab >actual &&
908 test_cmp expected actual
911 test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =extended' '
912 echo "ab:abc" >expected &&
914 -c grep.patterntype=fixed \
915 -c grep.patterntype=basic \
916 -c grep.patterntype=extended \
917 grep "a+b*c" ab >actual &&
918 test_cmp expected actual
921 test_expect_success 'grep -G -F -P -E pattern' '
923 test_must_fail git grep -G -F -P -E "a\x{2b}b\x{2a}c" ab >actual &&
924 test_cmp empty actual
927 test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =perl, =extended' '
930 -c grep.patterntype=fixed \
931 -c grep.patterntype=basic \
932 -c grep.patterntype=perl \
933 -c grep.patterntype=extended \
934 grep "a\x{2b}b\x{2a}c" ab >actual &&
935 test_cmp empty actual
938 test_expect_success LIBPCRE 'grep -G -F -E -P pattern' '
939 echo "ab:a+b*c" >expected &&
940 git grep -G -F -E -P "a\x{2b}b\x{2a}c" ab >actual &&
941 test_cmp expected actual
944 test_expect_success LIBPCRE 'grep pattern with grep.patternType=fixed, =basic, =extended, =perl' '
945 echo "ab:a+b*c" >expected &&
947 -c grep.patterntype=fixed \
948 -c grep.patterntype=basic \
949 -c grep.patterntype=extended \
950 -c grep.patterntype=perl \
951 grep "a\x{2b}b\x{2a}c" ab >actual &&
952 test_cmp expected actual
955 test_expect_success LIBPCRE 'grep -P pattern with grep.patternType=fixed' '
956 echo "ab:a+b*c" >expected &&
958 -c grep.patterntype=fixed \
959 grep -P "a\x{2b}b\x{2a}c" ab >actual &&
960 test_cmp expected actual
963 test_expect_success 'grep -F pattern with grep.patternType=basic' '
964 echo "ab:a+b*c" >expected &&
966 -c grep.patterntype=basic \
967 grep -F "*c" ab >actual &&
968 test_cmp expected actual
971 test_expect_success 'grep -G pattern with grep.patternType=fixed' '
977 -c grep.patterntype=fixed \
978 grep -G "a+b" ab >actual &&
979 test_cmp expected actual
982 test_expect_success 'grep -E pattern with grep.patternType=fixed' '
989 -c grep.patterntype=fixed \
990 grep -E "a+" ab >actual &&
991 test_cmp expected actual
995 git config "$1" "$2" &&
996 test_when_finished "git config --unset $1"
1000 hello.c<RED>:<RESET>int main(int argc, const char **argv)
1001 hello.c<RED>-<RESET>{
1003 hello.c<RED>:<RESET> /* char ?? */
1004 hello.c<RED>-<RESET>}
1006 hello_world<RED>:<RESET>Hello_world
1007 hello_world<RED>-<RESET>HeLLo_world
1010 test_expect_success 'grep --color, separator' '
1011 test_config color.grep.context normal &&
1012 test_config color.grep.filename normal &&
1013 test_config color.grep.function normal &&
1014 test_config color.grep.linenumber normal &&
1015 test_config color.grep.match normal &&
1016 test_config color.grep.selected normal &&
1017 test_config color.grep.separator red &&
1019 git grep --color=always -A1 -e char -e lo_w hello.c hello_world |
1020 test_decode_color >actual &&
1021 test_cmp expected actual
1025 hello.c:int main(int argc, const char **argv)
1026 hello.c: /* char ?? */
1028 hello_world:Hello_world
1031 test_expect_success 'grep --break' '
1032 git grep --break -e char -e lo_w hello.c hello_world >actual &&
1033 test_cmp expected actual
1037 hello.c:int main(int argc, const char **argv)
1040 hello.c: /* char ?? */
1043 hello_world:Hello_world
1044 hello_world-HeLLo_world
1047 test_expect_success 'grep --break with context' '
1048 git grep --break -A1 -e char -e lo_w hello.c hello_world >actual &&
1049 test_cmp expected actual
1054 int main(int argc, const char **argv)
1060 test_expect_success 'grep --heading' '
1061 git grep --heading -e char -e lo_w hello.c hello_world >actual &&
1062 test_cmp expected actual
1066 <BOLD;GREEN>hello.c<RESET>
1067 2:int main(int argc, const <BLACK;BYELLOW>char<RESET> **argv)
1068 6: /* <BLACK;BYELLOW>char<RESET> ?? */
1070 <BOLD;GREEN>hello_world<RESET>
1071 3:Hel<BLACK;BYELLOW>lo_w<RESET>orld
1074 test_expect_success 'mimic ack-grep --group' '
1075 test_config color.grep.context normal &&
1076 test_config color.grep.filename "bold green" &&
1077 test_config color.grep.function normal &&
1078 test_config color.grep.linenumber normal &&
1079 test_config color.grep.match "black yellow" &&
1080 test_config color.grep.selected normal &&
1081 test_config color.grep.separator normal &&
1083 git grep --break --heading -n --color \
1084 -e char -e lo_w hello.c hello_world |
1085 test_decode_color >actual &&
1086 test_cmp expected actual
1090 space: line with leading space1
1091 space: line with leading space2
1092 space: line with leading space3
1095 test_expect_success LIBPCRE 'grep -E "^ "' '
1096 git grep -E "^ " space >actual &&
1097 test_cmp expected actual
1100 test_expect_success LIBPCRE 'grep -P "^ "' '
1101 git grep -P "^ " space >actual &&
1102 test_cmp expected actual