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 &&
32 HEAD
) HC
='HEAD:' L
='HEAD' ;;
33 '') HC
= L
='in working tree' ;;
36 test_expect_success
"grep -w $L" '
38 echo ${HC}file:1:foo mmap bar
39 echo ${HC}file:3:foo_mmap bar mmap
40 echo ${HC}file:4:foo mmap bar_mmap
41 echo ${HC}file:5:foo_mmap bar mmap baz
43 git grep -n -w -e mmap $H >actual &&
47 test_expect_success
"grep -w $L (x)" '
49 echo ${HC}x:1:x x xx x
51 git grep -n -w -e "x xx* x" $H >actual &&
55 test_expect_success
"grep -w $L (y-1)" '
59 git grep -n -w -e "^y" $H >actual &&
63 test_expect_success
"grep -w $L (y-2)" '
65 if git grep -n -w -e "^y y" $H >actual
67 echo should not have matched
75 test_expect_success
"grep -w $L (z)" '
77 if git grep -n -w -e "^z" $H >actual
79 echo should not have matched
87 test_expect_success
"grep $L (t-1)" '
88 echo "${HC}t/t:1:test" >expected &&
89 git grep -n -e test $H >actual &&
93 test_expect_success
"grep $L (t-2)" '
94 echo "${HC}t:1:test" >expected &&
97 git grep -n -e test $H
102 test_expect_success
"grep $L (t-3)" '
103 echo "${HC}t/t:1:test" >expected &&
106 git grep --full-name -n -e test $H
111 test_expect_success
"grep -c $L (no /dev/null)" '
112 ! git grep -c test $H | grep -q /dev/null
117 test_expect_success
'log grep setup' '
120 GIT_AUTHOR_NAME="With * Asterisk" \
121 GIT_AUTHOR_EMAIL="xyzzy@frotz.com" \
122 git commit -a -m "second" &&
126 git commit -a -m "third"
130 test_expect_success
'log grep (1)' '
131 git log --author=author --pretty=tformat:%s >actual &&
132 ( echo third ; echo initial ) >expect &&
133 test_cmp expect actual
136 test_expect_success
'log grep (2)' '
137 git log --author=" * " -F --pretty=tformat:%s >actual &&
138 ( echo second ) >expect &&
139 test_cmp expect actual
142 test_expect_success
'log grep (3)' '
143 git log --author="^A U" --pretty=tformat:%s >actual &&
144 ( echo third ; echo initial ) >expect &&
145 test_cmp expect actual
148 test_expect_success
'log grep (4)' '
149 git log --author="frotz\.com>$" --pretty=tformat:%s >actual &&
150 ( echo second ) >expect &&
151 test_cmp expect actual
154 test_expect_success
'log grep (5)' '
155 git log --author=Thor -F --grep=Thu --pretty=tformat:%s >actual &&
156 ( echo third ; echo initial ) >expect &&
157 test_cmp expect actual
160 test_expect_success
'log grep (6)' '
161 git log --author=-0700 --pretty=tformat:%s >actual &&
163 test_cmp expect actual