3 # Copyright (c) 2006 Junio C Hamano
6 test_description='git grep various.
11 test_expect_success setup '
15 echo foo_mmap bar mmap
16 echo foo mmap bar_mmap
17 echo foo_mmap bar mmap baz
24 git add file x y z t/t &&
31 HEAD) HC='HEAD:' L='HEAD' ;;
32 '') HC= L='in working tree' ;;
35 test_expect_success "grep -w $L" '
37 echo ${HC}file:1:foo mmap bar
38 echo ${HC}file:3:foo_mmap bar mmap
39 echo ${HC}file:4:foo mmap bar_mmap
40 echo ${HC}file:5:foo_mmap bar mmap baz
42 git grep -n -w -e mmap $H >actual &&
46 test_expect_success "grep -w $L (x)" '
48 echo ${HC}x:1:x x xx x
50 git grep -n -w -e "x xx* x" $H >actual &&
54 test_expect_success "grep -w $L (y-1)" '
58 git grep -n -w -e "^y" $H >actual &&
62 test_expect_success "grep -w $L (y-2)" '
64 if git grep -n -w -e "^y y" $H >actual
66 echo should not have matched
74 test_expect_success "grep -w $L (z)" '
76 if git grep -n -w -e "^z" $H >actual
78 echo should not have matched
86 test_expect_success "grep $L (t-1)" '
87 echo "${HC}t/t:1:test" >expected &&
88 git grep -n -e test $H >actual &&
92 test_expect_success "grep $L (t-2)" '
93 echo "${HC}t:1:test" >expected &&
96 git grep -n -e test $H
101 test_expect_success "grep $L (t-3)" '
102 echo "${HC}t/t:1:test" >expected &&
105 git grep --full-name -n -e test $H