Skip to content

Commit 5a9830c

Browse files
sunshinecogitster
authored andcommitted
t8001/t8002 (blame): add blame -L :funcname tests
git-blame inherited "-L :funcname" support when "-L :funcname:file" was implemented for git-log. Add tests. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 03e15fc commit 5a9830c

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

t/annotate-tests.sh

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33

44
check_count () {
55
head= &&
6+
file='file' &&
67
options= &&
78
while :
89
do
910
case "$1" in
1011
-h) head="$2"; shift; shift ;;
12+
-f) file="$2"; shift; shift ;;
1113
-*) options="$options $1"; shift ;;
1214
*) break ;;
1315
esac
1416
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 &&
1719
perl -e '
1820
my %expect = (@ARGV);
1921
my %count = map { $_ => 0 } keys %expect;
@@ -231,6 +233,48 @@ test_expect_success 'blame -L ,Y (Y > nlines)' '
231233
test_must_fail $PROG -L,12345 file
232234
'
233235

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+
234278
test_expect_success 'blame -L bogus' '
235279
test_must_fail $PROG -L file &&
236280
test_must_fail $PROG -L1,+ file &&

0 commit comments

Comments
 (0)