1#!/bin/sh
23
test_description='test log -L'
4. ./test-lib.sh
56
test_expect_success 'setup (import history)' '
7git fast-import < "$TEST_DIRECTORY"/t4211/history.export &&
8git reset --hard
9'
1011
canned_test_1 () {
12test_expect_$1 "$2" "
13git log $2 >actual &&
14test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$3 actual
15"
16}
1718
canned_test () {
19canned_test_1 success "$@"
20}
21canned_test_failure () {
22canned_test_1 failure "$@"
23}
2425
test_bad_opts () {
26test_expect_success "invalid args: $1" "
27test_must_fail git log $1 2>errors &&
28grep '$2' errors
29"
30}
3132
canned_test "-L 4,12:a.c simple" simple-f
33canned_test "-L 4,+9:a.c simple" simple-f
34canned_test "-L '/long f/,/^}/:a.c' simple" simple-f
35canned_test "-L :f:a.c simple" simple-f-to-main
3637
canned_test "-L '/main/,/^}/:a.c' simple" simple-main
38canned_test "-L :main:a.c simple" simple-main-to-end
3940
canned_test "-L 1,+4:a.c simple" beginning-of-file
4142
canned_test "-L 20:a.c simple" end-of-file
4344
canned_test "-L '/long f/',/^}/:a.c -L /main/,/^}/:a.c simple" two-ranges
45canned_test "-L 24,+1:a.c simple" vanishes-early
4647
canned_test "-M -L '/long f/,/^}/:b.c' move-support" move-support-f
48canned_test "-M -L ':f:b.c' parallel-change" parallel-change-f-to-main
4950
canned_test "-L 4,12:a.c -L :main:a.c simple" multiple
51canned_test "-L 4,18:a.c -L :main:a.c simple" multiple-overlapping
52canned_test "-L :main:a.c -L 4,18:a.c simple" multiple-overlapping
53canned_test "-L 4:a.c -L 8,12:a.c simple" multiple-superset
54canned_test "-L 8,12:a.c -L 4:a.c simple" multiple-superset
5556
test_bad_opts "-L" "switch.*requires a value"
57test_bad_opts "-L b.c" "argument.*not of the form"
58test_bad_opts "-L 1:" "argument.*not of the form"
59test_bad_opts "-L 1:nonexistent" "There is no path"
60test_bad_opts "-L 1:simple" "There is no path"
61test_bad_opts "-L '/foo:b.c'" "argument.*not of the form"
62test_bad_opts "-L 1000:b.c" "has only.*lines"
63test_bad_opts "-L 1,1000:b.c" "has only.*lines"
64test_bad_opts "-L :b.c" "argument.*not of the form"
65test_bad_opts "-L :foo:b.c" "no match"
6667
test_done