|
3 | 3 |
|
4 | 4 | check_count () {
|
5 | 5 | head= &&
|
| 6 | + file='file' && |
6 | 7 | options= &&
|
7 | 8 | while :
|
8 | 9 | do
|
9 | 10 | case "$1" in
|
10 | 11 | -h) head="$2"; shift; shift ;;
|
| 12 | + -f) file="$2"; shift; shift ;; |
11 | 13 | -*) options="$options $1"; shift ;;
|
12 | 14 | *) break ;;
|
13 | 15 | esac
|
14 | 16 | done &&
|
15 |
| - echo "$PROG $options file $head" >&4 && |
16 |
| - $PROG $options file $head >actual && |
| 17 | + echo "$PROG $options $file $head" >&4 && |
| 18 | + $PROG $options $file $head >actual && |
17 | 19 | perl -e '
|
18 | 20 | my %expect = (@ARGV);
|
19 | 21 | my %count = map { $_ => 0 } keys %expect;
|
@@ -231,6 +233,48 @@ test_expect_success 'blame -L ,Y (Y > nlines)' '
|
231 | 233 | test_must_fail $PROG -L,12345 file
|
232 | 234 | '
|
233 | 235 |
|
| 236 | +test_expect_success 'setup -L :regex' ' |
| 237 | + tr Q "\\t" >hello.c <<-\EOF && |
| 238 | + int main(int argc, const char *argv[]) |
| 239 | + { |
| 240 | + Qputs("hello"); |
| 241 | + } |
| 242 | + EOF |
| 243 | + git add hello.c && |
| 244 | + GIT_AUTHOR_NAME="F" GIT_AUTHOR_EMAIL="[email protected]" \ |
| 245 | + git commit -m "hello" && |
| 246 | +
|
| 247 | + mv hello.c hello.orig && |
| 248 | + sed -e "/}/i\\ |
| 249 | + Qputs(\"goodbye\");" <hello.orig | tr Q "\\t" >hello.c && |
| 250 | + GIT_AUTHOR_NAME="G" GIT_AUTHOR_EMAIL="[email protected]" \ |
| 251 | + git commit -a -m "goodbye" && |
| 252 | +
|
| 253 | + mv hello.c hello.orig && |
| 254 | + echo "#include <stdio.h>" >hello.c && |
| 255 | + cat hello.orig >>hello.c && |
| 256 | + tr Q "\\t" >>hello.c <<-\EOF |
| 257 | + void mail() |
| 258 | + { |
| 259 | + Qputs("mail"); |
| 260 | + } |
| 261 | + EOF |
| 262 | + GIT_AUTHOR_NAME="H" GIT_AUTHOR_EMAIL="[email protected]" \ |
| 263 | + git commit -a -m "mail" |
| 264 | +' |
| 265 | + |
| 266 | +test_expect_success 'blame -L :literal' ' |
| 267 | + check_count -f hello.c -L:main F 4 G 1 |
| 268 | +' |
| 269 | + |
| 270 | +test_expect_success 'blame -L :regex' ' |
| 271 | + check_count -f hello.c "-L:m[a-z][a-z]l" H 4 |
| 272 | +' |
| 273 | + |
| 274 | +test_expect_success 'blame -L :nomatch' ' |
| 275 | + test_must_fail $PROG -L:nomatch hello.c |
| 276 | +' |
| 277 | + |
234 | 278 | test_expect_success 'blame -L bogus' '
|
235 | 279 | test_must_fail $PROG -L file &&
|
236 | 280 | test_must_fail $PROG -L1,+ file &&
|
|
0 commit comments