MSVC: require pton and ntop emulation
[git/dscho.git] / t / t7810-grep.sh
blob75f4716d8cbca0c295668e181a557b186cb37432
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='git grep various.
9 . ./test-lib.sh
11 cat >hello.c <<EOF
12 #include <stdio.h>
13 int main(int argc, const char **argv)
15 printf("Hello world.\n");
16 return 0;
17 /* char ?? */
19 EOF
21 test_expect_success setup '
23 echo foo mmap bar
24 echo foo_mmap bar
25 echo foo_mmap bar mmap
26 echo foo mmap bar_mmap
27 echo foo_mmap bar mmap baz
28 } >file &&
30 echo Hello world
31 echo HeLLo world
32 echo Hello_world
33 echo HeLLo_world
34 } >hello_world &&
36 echo "a+b*c"
37 echo "a+bc"
38 echo "abc"
39 } >ab &&
40 echo vvv >v &&
41 echo ww w >w &&
42 echo x x xx x >x &&
43 echo y yy >y &&
44 echo zzz > z &&
45 mkdir t &&
46 echo test >t/t &&
47 echo vvv >t/v &&
48 mkdir t/a &&
49 echo vvv >t/a/v &&
50 git add . &&
51 test_tick &&
52 git commit -m initial
55 test_expect_success 'grep should not segfault with a bad input' '
56 test_must_fail git grep "("
59 for H in HEAD ''
61 case "$H" in
62 HEAD) HC='HEAD:' L='HEAD' ;;
63 '') HC= L='in working tree' ;;
64 esac
66 test_expect_success "grep -w $L" '
68 echo ${HC}file:1:foo mmap bar
69 echo ${HC}file:3:foo_mmap bar mmap
70 echo ${HC}file:4:foo mmap bar_mmap
71 echo ${HC}file:5:foo_mmap bar mmap baz
72 } >expected &&
73 git -c grep.linenumber=false grep -n -w -e mmap $H >actual &&
74 test_cmp expected actual
77 test_expect_success "grep -w $L" '
79 echo ${HC}file:1:foo mmap bar
80 echo ${HC}file:3:foo_mmap bar mmap
81 echo ${HC}file:4:foo mmap bar_mmap
82 echo ${HC}file:5:foo_mmap bar mmap baz
83 } >expected &&
84 git -c grep.linenumber=true grep -w -e mmap $H >actual &&
85 test_cmp expected actual
88 test_expect_success "grep -w $L" '
90 echo ${HC}file:foo mmap bar
91 echo ${HC}file:foo_mmap bar mmap
92 echo ${HC}file:foo mmap bar_mmap
93 echo ${HC}file:foo_mmap bar mmap baz
94 } >expected &&
95 git -c grep.linenumber=true grep --no-line-number -w -e mmap $H >actual &&
96 test_cmp expected actual
99 test_expect_success "grep -w $L (w)" '
100 : >expected &&
101 test_must_fail git grep -n -w -e "^w" >actual &&
102 test_cmp expected actual
105 test_expect_success "grep -w $L (x)" '
107 echo ${HC}x:1:x x xx x
108 } >expected &&
109 git grep -n -w -e "x xx* x" $H >actual &&
110 test_cmp expected actual
113 test_expect_success "grep -w $L (y-1)" '
115 echo ${HC}y:1:y yy
116 } >expected &&
117 git grep -n -w -e "^y" $H >actual &&
118 test_cmp expected actual
121 test_expect_success "grep -w $L (y-2)" '
122 : >expected &&
123 if git grep -n -w -e "^y y" $H >actual
124 then
125 echo should not have matched
126 cat actual
127 false
128 else
129 test_cmp expected actual
133 test_expect_success "grep -w $L (z)" '
134 : >expected &&
135 if git grep -n -w -e "^z" $H >actual
136 then
137 echo should not have matched
138 cat actual
139 false
140 else
141 test_cmp expected actual
145 test_expect_success "grep $L (t-1)" '
146 echo "${HC}t/t:1:test" >expected &&
147 git grep -n -e test $H >actual &&
148 test_cmp expected actual
151 test_expect_success "grep $L (t-2)" '
152 echo "${HC}t:1:test" >expected &&
154 cd t &&
155 git grep -n -e test $H
156 ) >actual &&
157 test_cmp expected actual
160 test_expect_success "grep $L (t-3)" '
161 echo "${HC}t/t:1:test" >expected &&
163 cd t &&
164 git grep --full-name -n -e test $H
165 ) >actual &&
166 test_cmp expected actual
169 test_expect_success "grep -c $L (no /dev/null)" '
170 ! git grep -c test $H | grep /dev/null
173 test_expect_success "grep --max-depth -1 $L" '
175 echo ${HC}t/a/v:1:vvv
176 echo ${HC}t/v:1:vvv
177 echo ${HC}v:1:vvv
178 } >expected &&
179 git grep --max-depth -1 -n -e vvv $H >actual &&
180 test_cmp expected actual
183 test_expect_success "grep --max-depth 0 $L" '
185 echo ${HC}v:1:vvv
186 } >expected &&
187 git grep --max-depth 0 -n -e vvv $H >actual &&
188 test_cmp expected actual
191 test_expect_success "grep --max-depth 0 -- '*' $L" '
193 echo ${HC}t/a/v:1:vvv
194 echo ${HC}t/v:1:vvv
195 echo ${HC}v:1:vvv
196 } >expected &&
197 git grep --max-depth 0 -n -e vvv $H -- "*" >actual &&
198 test_cmp expected actual
201 test_expect_success "grep --max-depth 1 $L" '
203 echo ${HC}t/v:1:vvv
204 echo ${HC}v:1:vvv
205 } >expected &&
206 git grep --max-depth 1 -n -e vvv $H >actual &&
207 test_cmp expected actual
210 test_expect_success "grep --max-depth 0 -- t $L" '
212 echo ${HC}t/v:1:vvv
213 } >expected &&
214 git grep --max-depth 0 -n -e vvv $H -- t >actual &&
215 test_cmp expected actual
218 test_expect_success "grep --max-depth 0 -- . t $L" '
220 echo ${HC}t/v:1:vvv
221 echo ${HC}v:1:vvv
222 } >expected &&
223 git grep --max-depth 0 -n -e vvv $H -- . t >actual &&
224 test_cmp expected actual
227 test_expect_success "grep --max-depth 0 -- t . $L" '
229 echo ${HC}t/v:1:vvv
230 echo ${HC}v:1:vvv
231 } >expected &&
232 git grep --max-depth 0 -n -e vvv $H -- t . >actual &&
233 test_cmp expected actual
235 test_expect_success "grep $L with grep.extendedRegexp=false" '
236 echo "ab:a+bc" >expected &&
237 git -c grep.extendedRegexp=false grep "a+b*c" ab >actual &&
238 test_cmp expected actual
241 test_expect_success "grep $L with grep.extendedRegexp=true" '
242 echo "ab:abc" >expected &&
243 git -c grep.extendedRegexp=true grep "a+b*c" ab >actual &&
244 test_cmp expected actual
246 done
248 cat >expected <<EOF
249 file
251 test_expect_success 'grep -l -C' '
252 git grep -l -C1 foo >actual &&
253 test_cmp expected actual
256 cat >expected <<EOF
257 file:5
259 test_expect_success 'grep -l -C' '
260 git grep -c -C1 foo >actual &&
261 test_cmp expected actual
264 test_expect_success 'grep -L -C' '
265 git ls-files >expected &&
266 git grep -L -C1 nonexistent_string >actual &&
267 test_cmp expected actual
270 cat >expected <<EOF
271 file:foo mmap bar_mmap
274 test_expect_success 'grep -e A --and -e B' '
275 git grep -e "foo mmap" --and -e bar_mmap >actual &&
276 test_cmp expected actual
279 cat >expected <<EOF
280 file:foo_mmap bar mmap
281 file:foo_mmap bar mmap baz
285 test_expect_success 'grep ( -e A --or -e B ) --and -e B' '
286 git grep \( -e foo_ --or -e baz \) \
287 --and -e " mmap" >actual &&
288 test_cmp expected actual
291 cat >expected <<EOF
292 file:foo mmap bar
295 test_expect_success 'grep -e A --and --not -e B' '
296 git grep -e "foo mmap" --and --not -e bar_mmap >actual &&
297 test_cmp expected actual
300 test_expect_success 'grep should ignore GREP_OPTIONS' '
301 GREP_OPTIONS=-v git grep " mmap bar\$" >actual &&
302 test_cmp expected actual
305 test_expect_success 'grep -f, non-existent file' '
306 test_must_fail git grep -f patterns
309 cat >expected <<EOF
310 file:foo mmap bar
311 file:foo_mmap bar
312 file:foo_mmap bar mmap
313 file:foo mmap bar_mmap
314 file:foo_mmap bar mmap baz
317 cat >pattern <<EOF
318 mmap
321 test_expect_success 'grep -f, one pattern' '
322 git grep -f pattern >actual &&
323 test_cmp expected actual
326 cat >expected <<EOF
327 file:foo mmap bar
328 file:foo_mmap bar
329 file:foo_mmap bar mmap
330 file:foo mmap bar_mmap
331 file:foo_mmap bar mmap baz
332 t/a/v:vvv
333 t/v:vvv
334 v:vvv
337 cat >patterns <<EOF
338 mmap
342 test_expect_success 'grep -f, multiple patterns' '
343 git grep -f patterns >actual &&
344 test_cmp expected actual
347 cat >expected <<EOF
348 file:foo mmap bar
349 file:foo_mmap bar
350 file:foo_mmap bar mmap
351 file:foo mmap bar_mmap
352 file:foo_mmap bar mmap baz
353 t/a/v:vvv
354 t/v:vvv
355 v:vvv
358 cat >patterns <<EOF
360 mmap
366 test_expect_success 'grep -f, ignore empty lines' '
367 git grep -f patterns >actual &&
368 test_cmp expected actual
371 test_expect_success 'grep -f, ignore empty lines, read patterns from stdin' '
372 git grep -f - <patterns >actual &&
373 test_cmp expected actual
376 cat >expected <<EOF
377 y:y yy
379 z:zzz
382 test_expect_success 'grep -q, silently report matches' '
383 >empty &&
384 git grep -q mmap >actual &&
385 test_cmp empty actual &&
386 test_must_fail git grep -q qfwfq >actual &&
387 test_cmp empty actual
390 # Create 1024 file names that sort between "y" and "z" to make sure
391 # the two files are handled by different calls to an external grep.
392 # This depends on MAXARGS in builtin-grep.c being 1024 or less.
393 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"
394 test_expect_success 'grep -C1, hunk mark between files' '
395 for a in $c32; do for b in $c32; do : >y-$a$b; done; done &&
396 git add y-?? &&
397 git grep -C1 "^[yz]" >actual &&
398 test_cmp expected actual
401 test_expect_success 'grep -C1 hunk mark between files' '
402 git grep -C1 "^[yz]" >actual &&
403 test_cmp expected actual
406 test_expect_success 'log grep setup' '
407 echo a >>file &&
408 test_tick &&
409 GIT_AUTHOR_NAME="With * Asterisk" \
410 GIT_AUTHOR_EMAIL="xyzzy@frotz.com" \
411 git commit -a -m "second" &&
413 echo a >>file &&
414 test_tick &&
415 git commit -a -m "third" &&
417 echo a >>file &&
418 test_tick &&
419 GIT_AUTHOR_NAME="Night Fall" \
420 GIT_AUTHOR_EMAIL="nitfol@frobozz.com" \
421 git commit -a -m "fourth"
424 test_expect_success 'log grep (1)' '
425 git log --author=author --pretty=tformat:%s >actual &&
426 ( echo third ; echo initial ) >expect &&
427 test_cmp expect actual
430 test_expect_success 'log grep (2)' '
431 git log --author=" * " -F --pretty=tformat:%s >actual &&
432 ( echo second ) >expect &&
433 test_cmp expect actual
436 test_expect_success 'log grep (3)' '
437 git log --author="^A U" --pretty=tformat:%s >actual &&
438 ( echo third ; echo initial ) >expect &&
439 test_cmp expect actual
442 test_expect_success 'log grep (4)' '
443 git log --author="frotz\.com>$" --pretty=tformat:%s >actual &&
444 ( echo second ) >expect &&
445 test_cmp expect actual
448 test_expect_success 'log grep (5)' '
449 git log --author=Thor -F --pretty=tformat:%s >actual &&
450 ( echo third ; echo initial ) >expect &&
451 test_cmp expect actual
454 test_expect_success 'log grep (6)' '
455 git log --author=-0700 --pretty=tformat:%s >actual &&
456 >expect &&
457 test_cmp expect actual
460 test_expect_success 'log --grep --author implicitly uses all-match' '
461 # grep matches initial and second but not third
462 # author matches only initial and third
463 git log --author="A U Thor" --grep=s --grep=l --format=%s >actual &&
464 echo initial >expect &&
465 test_cmp expect actual
468 test_expect_success 'log with multiple --author uses union' '
469 git log --author="Thor" --author="Aster" --format=%s >actual &&
471 echo third && echo second && echo initial
472 } >expect &&
473 test_cmp expect actual
476 test_expect_success 'log with --grep and multiple --author uses all-match' '
477 git log --author="Thor" --author="Night" --grep=i --format=%s >actual &&
479 echo third && echo initial
480 } >expect &&
481 test_cmp expect actual
484 test_expect_success 'log with --grep and multiple --author uses all-match' '
485 git log --author="Thor" --author="Night" --grep=q --format=%s >actual &&
486 >expect &&
487 test_cmp expect actual
490 test_expect_success 'grep with CE_VALID file' '
491 git update-index --assume-unchanged t/t &&
492 rm t/t &&
493 test "$(git grep test)" = "t/t:test" &&
494 git update-index --no-assume-unchanged t/t &&
495 git checkout t/t
498 cat >expected <<EOF
499 hello.c=#include <stdio.h>
500 hello.c: return 0;
503 test_expect_success 'grep -p with userdiff' '
504 git config diff.custom.funcname "^#" &&
505 echo "hello.c diff=custom" >.gitattributes &&
506 git grep -p return >actual &&
507 test_cmp expected actual
510 cat >expected <<EOF
511 hello.c=int main(int argc, const char **argv)
512 hello.c: return 0;
515 test_expect_success 'grep -p' '
516 rm -f .gitattributes &&
517 git grep -p return >actual &&
518 test_cmp expected actual
521 cat >expected <<EOF
522 hello.c-#include <stdio.h>
523 hello.c=int main(int argc, const char **argv)
524 hello.c-{
525 hello.c- printf("Hello world.\n");
526 hello.c: return 0;
529 test_expect_success 'grep -p -B5' '
530 git grep -p -B5 return >actual &&
531 test_cmp expected actual
534 cat >expected <<EOF
535 hello.c=int main(int argc, const char **argv)
536 hello.c-{
537 hello.c- printf("Hello world.\n");
538 hello.c: return 0;
539 hello.c- /* char ?? */
540 hello.c-}
543 test_expect_success 'grep -W' '
544 git grep -W return >actual &&
545 test_cmp expected actual
548 cat >expected <<EOF
549 hello.c= printf("Hello world.\n");
550 hello.c: return 0;
551 hello.c- /* char ?? */
554 test_expect_success 'grep -W with userdiff' '
555 test_when_finished "rm -f .gitattributes" &&
556 git config diff.custom.xfuncname "(printf.*|})$" &&
557 echo "hello.c diff=custom" >.gitattributes &&
558 git grep -W return >actual &&
559 test_cmp expected actual
562 test_expect_success 'grep from a subdirectory to search wider area (1)' '
563 mkdir -p s &&
565 cd s && git grep "x x x" ..
569 test_expect_success 'grep from a subdirectory to search wider area (2)' '
570 mkdir -p s &&
572 cd s || exit 1
573 ( git grep xxyyzz .. >out ; echo $? >status )
574 ! test -s out &&
575 test 1 = $(cat status)
579 cat >expected <<EOF
580 hello.c:int main(int argc, const char **argv)
583 test_expect_success 'grep -Fi' '
584 git grep -Fi "CHAR *" >actual &&
585 test_cmp expected actual
588 test_expect_success 'outside of git repository' '
589 rm -fr non &&
590 mkdir -p non/git/sub &&
591 echo hello >non/git/file1 &&
592 echo world >non/git/sub/file2 &&
594 echo file1:hello &&
595 echo sub/file2:world
596 } >non/expect.full &&
597 echo file2:world >non/expect.sub &&
599 GIT_CEILING_DIRECTORIES="$(pwd)/non/git" &&
600 export GIT_CEILING_DIRECTORIES &&
601 cd non/git &&
602 test_must_fail git grep o &&
603 git grep --no-index o >../actual.full &&
604 test_cmp ../expect.full ../actual.full
605 cd sub &&
606 test_must_fail git grep o &&
607 git grep --no-index o >../../actual.sub &&
608 test_cmp ../../expect.sub ../../actual.sub
609 ) &&
611 echo ".*o*" >non/git/.gitignore &&
613 GIT_CEILING_DIRECTORIES="$(pwd)/non/git" &&
614 export GIT_CEILING_DIRECTORIES &&
615 cd non/git &&
616 test_must_fail git grep o &&
617 git grep --no-index --exclude-standard o >../actual.full &&
618 test_cmp ../expect.full ../actual.full &&
621 echo ".gitignore:.*o*"
622 cat ../expect.full
623 } >../expect.with.ignored &&
624 git grep --no-index --no-exclude o >../actual.full &&
625 test_cmp ../expect.with.ignored ../actual.full
629 test_expect_success 'inside git repository but with --no-index' '
630 rm -fr is &&
631 mkdir -p is/git/sub &&
632 echo hello >is/git/file1 &&
633 echo world >is/git/sub/file2 &&
634 echo ".*o*" >is/git/.gitignore &&
636 echo file1:hello &&
637 echo sub/file2:world
638 } >is/expect.unignored &&
640 echo ".gitignore:.*o*" &&
641 cat is/expect.unignored
642 } >is/expect.full &&
643 : >is/expect.empty &&
644 echo file2:world >is/expect.sub &&
646 cd is/git &&
647 git init &&
648 test_must_fail git grep o >../actual.full &&
649 test_cmp ../expect.empty ../actual.full &&
651 git grep --untracked o >../actual.unignored &&
652 test_cmp ../expect.unignored ../actual.unignored &&
654 git grep --no-index o >../actual.full &&
655 test_cmp ../expect.full ../actual.full &&
657 git grep --no-index --exclude-standard o >../actual.unignored &&
658 test_cmp ../expect.unignored ../actual.unignored &&
660 cd sub &&
661 test_must_fail git grep o >../../actual.sub &&
662 test_cmp ../../expect.empty ../../actual.sub &&
664 git grep --no-index o >../../actual.sub &&
665 test_cmp ../../expect.sub ../../actual.sub &&
667 git grep --untracked o >../../actual.sub &&
668 test_cmp ../../expect.sub ../../actual.sub
672 test_expect_success 'setup double-dash tests' '
673 cat >double-dash <<EOF &&
676 other
678 git add double-dash
681 cat >expected <<EOF
682 double-dash:->
684 test_expect_success 'grep -- pattern' '
685 git grep -- "->" >actual &&
686 test_cmp expected actual
688 test_expect_success 'grep -- pattern -- pathspec' '
689 git grep -- "->" -- double-dash >actual &&
690 test_cmp expected actual
692 test_expect_success 'grep -e pattern -- path' '
693 git grep -e "->" -- double-dash >actual &&
694 test_cmp expected actual
697 cat >expected <<EOF
698 double-dash:--
700 test_expect_success 'grep -e -- -- path' '
701 git grep -e -- -- double-dash >actual &&
702 test_cmp expected actual
705 cat >expected <<EOF
706 hello.c:int main(int argc, const char **argv)
707 hello.c: printf("Hello world.\n");
710 test_expect_success LIBPCRE 'grep --perl-regexp pattern' '
711 git grep --perl-regexp "\p{Ps}.*?\p{Pe}" hello.c >actual &&
712 test_cmp expected actual
715 test_expect_success LIBPCRE 'grep -P pattern' '
716 git grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
717 test_cmp expected actual
720 test_expect_success 'grep pattern with grep.extendedRegexp=true' '
721 >empty &&
722 test_must_fail git -c grep.extendedregexp=true \
723 grep "\p{Ps}.*?\p{Pe}" hello.c >actual &&
724 test_cmp empty actual
727 test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=true' '
728 git -c grep.extendedregexp=true \
729 grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
730 test_cmp expected actual
733 test_expect_success LIBPCRE 'grep -P -v pattern' '
735 echo "ab:a+b*c"
736 echo "ab:a+bc"
737 } >expected &&
738 git grep -P -v "abc" ab >actual &&
739 test_cmp expected actual
742 test_expect_success LIBPCRE 'grep -P -i pattern' '
743 cat >expected <<-EOF &&
744 hello.c: printf("Hello world.\n");
746 git grep -P -i "PRINTF\([^\d]+\)" hello.c >actual &&
747 test_cmp expected actual
750 test_expect_success LIBPCRE 'grep -P -w pattern' '
752 echo "hello_world:Hello world"
753 echo "hello_world:HeLLo world"
754 } >expected &&
755 git grep -P -w "He((?i)ll)o" hello_world >actual &&
756 test_cmp expected actual
759 test_expect_success 'grep -G invalidpattern properly dies ' '
760 test_must_fail git grep -G "a["
763 test_expect_success 'grep -E invalidpattern properly dies ' '
764 test_must_fail git grep -E "a["
767 test_expect_success LIBPCRE 'grep -P invalidpattern properly dies ' '
768 test_must_fail git grep -P "a["
771 test_expect_success 'grep -G -E -F pattern' '
772 echo "ab:a+b*c" >expected &&
773 git grep -G -E -F "a+b*c" ab >actual &&
774 test_cmp expected actual
777 test_expect_success 'grep -E -F -G pattern' '
778 echo "ab:a+bc" >expected &&
779 git grep -E -F -G "a+b*c" ab >actual &&
780 test_cmp expected actual
783 test_expect_success 'grep -F -G -E pattern' '
784 echo "ab:abc" >expected &&
785 git grep -F -G -E "a+b*c" ab >actual &&
786 test_cmp expected actual
789 test_expect_success 'grep -G -F -P -E pattern' '
790 >empty &&
791 test_must_fail git grep -G -F -P -E "a\x{2b}b\x{2a}c" ab >actual &&
792 test_cmp empty actual
795 test_expect_success LIBPCRE 'grep -G -F -E -P pattern' '
796 echo "ab:a+b*c" >expected &&
797 git grep -G -F -E -P "a\x{2b}b\x{2a}c" ab >actual &&
798 test_cmp expected actual
801 test_config() {
802 git config "$1" "$2" &&
803 test_when_finished "git config --unset $1"
806 cat >expected <<EOF
807 hello.c<RED>:<RESET>int main(int argc, const char **argv)
808 hello.c<RED>-<RESET>{
809 <RED>--<RESET>
810 hello.c<RED>:<RESET> /* char ?? */
811 hello.c<RED>-<RESET>}
812 <RED>--<RESET>
813 hello_world<RED>:<RESET>Hello_world
814 hello_world<RED>-<RESET>HeLLo_world
817 test_expect_success 'grep --color, separator' '
818 test_config color.grep.context normal &&
819 test_config color.grep.filename normal &&
820 test_config color.grep.function normal &&
821 test_config color.grep.linenumber normal &&
822 test_config color.grep.match normal &&
823 test_config color.grep.selected normal &&
824 test_config color.grep.separator red &&
826 git grep --color=always -A1 -e char -e lo_w hello.c hello_world |
827 test_decode_color >actual &&
828 test_cmp expected actual
831 cat >expected <<EOF
832 hello.c:int main(int argc, const char **argv)
833 hello.c: /* char ?? */
835 hello_world:Hello_world
838 test_expect_success 'grep --break' '
839 git grep --break -e char -e lo_w hello.c hello_world >actual &&
840 test_cmp expected actual
843 cat >expected <<EOF
844 hello.c:int main(int argc, const char **argv)
845 hello.c-{
847 hello.c: /* char ?? */
848 hello.c-}
850 hello_world:Hello_world
851 hello_world-HeLLo_world
854 test_expect_success 'grep --break with context' '
855 git grep --break -A1 -e char -e lo_w hello.c hello_world >actual &&
856 test_cmp expected actual
859 cat >expected <<EOF
860 hello.c
861 int main(int argc, const char **argv)
862 /* char ?? */
863 hello_world
864 Hello_world
867 test_expect_success 'grep --heading' '
868 git grep --heading -e char -e lo_w hello.c hello_world >actual &&
869 test_cmp expected actual
872 cat >expected <<EOF
873 <BOLD;GREEN>hello.c<RESET>
874 2:int main(int argc, const <BLACK;BYELLOW>char<RESET> **argv)
875 6: /* <BLACK;BYELLOW>char<RESET> ?? */
877 <BOLD;GREEN>hello_world<RESET>
878 3:Hel<BLACK;BYELLOW>lo_w<RESET>orld
881 test_expect_success 'mimic ack-grep --group' '
882 test_config color.grep.context normal &&
883 test_config color.grep.filename "bold green" &&
884 test_config color.grep.function normal &&
885 test_config color.grep.linenumber normal &&
886 test_config color.grep.match "black yellow" &&
887 test_config color.grep.selected normal &&
888 test_config color.grep.separator normal &&
890 git grep --break --heading -n --color \
891 -e char -e lo_w hello.c hello_world |
892 test_decode_color >actual &&
893 test_cmp expected actual
896 test_done