From 91b5494e18965e51c924ca55aaa27e94ebd82dd2 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 6 Aug 2013 09:59:39 -0400 Subject: t8001/t8002: blame: add tests of multiple -L options Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/annotate-tests.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 't/annotate-tests.sh') diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index ce5b8ed304..77083d9dde 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -271,6 +271,38 @@ test_expect_success 'blame -L ,Y (Y > nlines)' ' test_must_fail $PROG -L,12345 file ' +test_expect_success 'blame -L multiple (disjoint)' ' + check_count -L2,3 -L6,7 A 1 B1 1 B2 1 "A U Thor" 1 +' + +test_expect_success 'blame -L multiple (disjoint: unordered)' ' + check_count -L6,7 -L2,3 A 1 B1 1 B2 1 "A U Thor" 1 +' + +test_expect_success 'blame -L multiple (adjacent)' ' + check_count -L2,3 -L4,5 A 1 B 1 B2 1 D 1 +' + +test_expect_success 'blame -L multiple (adjacent: unordered)' ' + check_count -L4,5 -L2,3 A 1 B 1 B2 1 D 1 +' + +test_expect_success 'blame -L multiple (overlapping)' ' + check_count -L2,4 -L3,5 A 1 B 1 B2 1 D 1 +' + +test_expect_success 'blame -L multiple (overlapping: unordered)' ' + check_count -L3,5 -L2,4 A 1 B 1 B2 1 D 1 +' + +test_expect_success 'blame -L multiple (superset/subset)' ' + check_count -L2,8 -L3,5 A 1 B 1 B1 1 B2 1 C 1 D 1 "A U Thor" 1 +' + +test_expect_success 'blame -L multiple (superset/subset: unordered)' ' + check_count -L3,5 -L2,8 A 1 B 1 B1 1 B2 1 C 1 D 1 "A U Thor" 1 +' + test_expect_success 'setup -L :regex' ' tr Q "\\t" >hello.c <<-\EOF && int main(int argc, const char *argv[]) -- cgit v1.2.3 From 52f4d1264854485bfd50afeeed1933a3f9e05c96 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 6 Aug 2013 09:59:42 -0400 Subject: blame: teach -L/RE/ to search from end of previous -L range Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/annotate-tests.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 't/annotate-tests.sh') diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 77083d9dde..b963d36325 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -303,6 +303,26 @@ test_expect_success 'blame -L multiple (superset/subset: unordered)' ' check_count -L3,5 -L2,8 A 1 B 1 B1 1 B2 1 C 1 D 1 "A U Thor" 1 ' +test_expect_success 'blame -L /RE/ (relative)' ' + check_count -L3,3 -L/fox/ B1 1 B2 1 C 1 D 1 "A U Thor" 1 +' + +test_expect_success 'blame -L /RE/ (relative: no preceding range)' ' + check_count -L/dog/ A 1 B 1 B1 1 B2 1 C 1 D 1 "A U Thor" 1 +' + +test_expect_success 'blame -L /RE/ (relative: adjacent)' ' + check_count -L1,1 -L/dog/,+1 A 1 E 1 +' + +test_expect_success 'blame -L /RE/ (relative: not found)' ' + test_must_fail $PROG -L4,4 -L/dog/ file +' + +test_expect_success 'blame -L /RE/ (relative: end-of-file)' ' + test_must_fail $PROG -L, -L/$/ file +' + test_expect_success 'setup -L :regex' ' tr Q "\\t" >hello.c <<-\EOF && int main(int argc, const char *argv[]) -- cgit v1.2.3 From a6ac5f9864958f65269d8d58a049324403b039fd Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 6 Aug 2013 09:59:45 -0400 Subject: line-range: teach -L^/RE/ to search from start of file The -L/RE/ option of blame/log searches from the end of the previous -L range, if any. Add new notation -L^/RE/ to override this behavior and search from start of file. The new ^/RE/ syntax is valid only as the argument of -L,. The argument, as usual, is relative to . Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/annotate-tests.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 't/annotate-tests.sh') diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index b963d36325..5a7d7c72d1 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -323,6 +323,23 @@ test_expect_success 'blame -L /RE/ (relative: end-of-file)' ' test_must_fail $PROG -L, -L/$/ file ' +test_expect_success 'blame -L ^/RE/ (absolute)' ' + check_count -L3,3 -L^/dog/,+2 A 1 B2 1 +' + +test_expect_success 'blame -L ^/RE/ (absolute: no preceding range)' ' + check_count -L^/dog/,+2 A 1 B2 1 +' + +test_expect_success 'blame -L ^/RE/ (absolute: not found)' ' + test_must_fail $PROG -L4,4 -L^/tambourine/ file +' + +test_expect_success 'blame -L ^/RE/ (absolute: end-of-file)' ' + n=$(expr $(wc -l hello.c <<-\EOF && int main(int argc, const char *argv[]) @@ -464,3 +481,7 @@ test_expect_success 'blame -L X,+N (non-numeric N)' ' test_expect_success 'blame -L X,-N (non-numeric N)' ' test_must_fail $PROG -L1,-N file ' + +test_expect_success 'blame -L ,^/RE/' ' + test_must_fail $PROG -L1,^/99/ file +' -- cgit v1.2.3 From 1ce761a524e34f2d629759cb57c67d13acbe4a7a Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 6 Aug 2013 09:59:46 -0400 Subject: line-range: teach -L:RE to search from end of previous -L range For consistency with -L/RE/, teach -L:RE to search relative to the end of the previous -L range, if any. The new behavior invalidates one test in t4211 which assumes that -L:RE begins searching at start of file. This test will be resurrected in a follow-up patch which teaches -L:RE how to override the default relative search behavior. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/annotate-tests.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't/annotate-tests.sh') diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 5a7d7c72d1..4f7d6baef5 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -382,6 +382,22 @@ test_expect_success 'blame -L :nomatch' ' test_must_fail $PROG -L:nomatch hello.c ' +test_expect_success 'blame -L :RE (relative)' ' + check_count -f hello.c -L3,3 -L:ma.. F 1 H 4 +' + +test_expect_success 'blame -L :RE (relative: no preceding range)' ' + check_count -f hello.c -L:ma.. F 4 G 1 +' + +test_expect_success 'blame -L :RE (relative: not found)' ' + test_must_fail $PROG -L3,3 -L:tambourine hello.c +' + +test_expect_success 'blame -L :RE (relative: end-of-file)' ' + test_must_fail $PROG -L, -L:main hello.c +' + test_expect_success 'setup incremental' ' ( GIT_AUTHOR_NAME=I && -- cgit v1.2.3 From 215e76c7ff8be46b8206c45aed3b6ec29069d4fc Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 6 Aug 2013 09:59:47 -0400 Subject: line-range: teach -L^:RE to search from start of file The -L:RE option of blame/log searches from the end of the previous -L range, if any. Add new notation -L^:RE to override this behavior and search from start of file. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/annotate-tests.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't/annotate-tests.sh') diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 4f7d6baef5..dabe89d91a 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -398,6 +398,23 @@ test_expect_success 'blame -L :RE (relative: end-of-file)' ' test_must_fail $PROG -L, -L:main hello.c ' +test_expect_success 'blame -L ^:RE (absolute)' ' + check_count -f hello.c -L3,3 -L^:ma.. F 4 G 1 +' + +test_expect_success 'blame -L ^:RE (absolute: no preceding range)' ' + check_count -f hello.c -L^:ma.. F 4 G 1 +' + +test_expect_success 'blame -L ^:RE (absolute: not found)' ' + test_must_fail $PROG -L4,4 -L^:tambourine hello.c +' + +test_expect_success 'blame -L ^:RE (absolute: end-of-file)' ' + n=$(printf "%d" $(wc -l Date: Tue, 6 Aug 2013 09:59:48 -0400 Subject: t8001/t8002: blame: add tests of -L line numbers less than 1 git-blame -L is documented as accepting 1-based line numbers. When handed a line number less than 1, -L's behavior is undocumented and undefined; it's also nonsensical and should be rejected but is nevertheless accepted. Demonstrate this shortcoming. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/annotate-tests.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 't/annotate-tests.sh') diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index dabe89d91a..376b042f2f 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -185,6 +185,18 @@ test_expect_success 'blame -L Y,X (undocumented)' ' check_count -L6,3 B 1 B1 1 B2 1 D 1 ' +test_expect_failure 'blame -L -X' ' + test_must_fail $PROG -L-1 file +' + +test_expect_failure 'blame -L 0' ' + test_must_fail $PROG -L0 file +' + +test_expect_failure 'blame -L ,0' ' + test_must_fail $PROG -L,0 file +' + test_expect_success 'blame -L ,+0' ' test_must_fail $PROG -L,+0 file ' -- cgit v1.2.3 From 5ce922a014f78684a96c3d03a51decf0d21fa58d Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 6 Aug 2013 09:59:49 -0400 Subject: line-range: reject -L line numbers less than 1 Since inception, git-blame -L has been documented as accepting 1-based line numbers. When handed a line number less than 1, -L's behavior is undocumented and undefined; it's also nonsensical and should be diagnosed as an error. Do so. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/annotate-tests.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 't/annotate-tests.sh') diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index 376b042f2f..99caa42f5c 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -185,15 +185,15 @@ test_expect_success 'blame -L Y,X (undocumented)' ' check_count -L6,3 B 1 B1 1 B2 1 D 1 ' -test_expect_failure 'blame -L -X' ' +test_expect_success 'blame -L -X' ' test_must_fail $PROG -L-1 file ' -test_expect_failure 'blame -L 0' ' +test_expect_success 'blame -L 0' ' test_must_fail $PROG -L0 file ' -test_expect_failure 'blame -L ,0' ' +test_expect_success 'blame -L ,0' ' test_must_fail $PROG -L,0 file ' @@ -447,8 +447,8 @@ test_expect_success 'blame empty' ' check_count -h HEAD^^ -f incremental ' -test_expect_success 'blame -L 0 empty (undocumented)' ' - check_count -h HEAD^^ -f incremental -L0 +test_expect_success 'blame -L 0 empty' ' + test_must_fail $PROG -L0 incremental HEAD^^ ' test_expect_success 'blame -L 1 empty' ' @@ -463,8 +463,8 @@ test_expect_success 'blame half' ' check_count -h HEAD^ -f incremental I 1 ' -test_expect_success 'blame -L 0 half (undocumented)' ' - check_count -h HEAD^ -f incremental -L0 I 1 +test_expect_success 'blame -L 0 half' ' + test_must_fail $PROG -L0 incremental HEAD^ ' test_expect_success 'blame -L 1 half' ' @@ -483,8 +483,8 @@ test_expect_success 'blame full' ' check_count -f incremental I 1 ' -test_expect_success 'blame -L 0 full (undocumented)' ' - check_count -f incremental -L0 I 1 +test_expect_success 'blame -L 0 full' ' + test_must_fail $PROG -L0 incremental ' test_expect_success 'blame -L 1 full' ' -- cgit v1.2.3