]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | test_description='test log -L' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_expect_success 'setup (import history)' ' | |
7 | git fast-import < "$TEST_DIRECTORY"/t4211/history.export && | |
8 | git reset --hard | |
9 | ' | |
10 | ||
11 | canned_test_1 () { | |
12 | test_expect_$1 "$2" " | |
13 | git log $2 >actual && | |
14 | test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$3 actual | |
15 | " | |
16 | } | |
17 | ||
18 | canned_test () { | |
19 | canned_test_1 success "$@" | |
20 | } | |
21 | canned_test_failure () { | |
22 | canned_test_1 failure "$@" | |
23 | } | |
24 | ||
25 | test_bad_opts () { | |
26 | test_expect_success "invalid args: $1" " | |
27 | test_must_fail git log $1 2>errors && | |
28 | test_i18ngrep '$2' errors | |
29 | " | |
30 | } | |
31 | ||
32 | canned_test "-L 4,12:a.c simple" simple-f | |
33 | canned_test "-L 4,+9:a.c simple" simple-f | |
34 | canned_test "-L '/long f/,/^}/:a.c' simple" simple-f | |
35 | canned_test "-L :f:a.c simple" simple-f-to-main | |
36 | ||
37 | canned_test "-L '/main/,/^}/:a.c' simple" simple-main | |
38 | canned_test "-L :main:a.c simple" simple-main-to-end | |
39 | ||
40 | canned_test "-L 1,+4:a.c simple" beginning-of-file | |
41 | ||
42 | canned_test "-L 20:a.c simple" end-of-file | |
43 | ||
44 | canned_test "-L '/long f/',/^}/:a.c -L /main/,/^}/:a.c simple" two-ranges | |
45 | canned_test "-L 24,+1:a.c simple" vanishes-early | |
46 | ||
47 | canned_test "-M -L '/long f/,/^}/:b.c' move-support" move-support-f | |
48 | canned_test "-M -L ':f:b.c' parallel-change" parallel-change-f-to-main | |
49 | ||
50 | canned_test "-L 4,12:a.c -L :main:a.c simple" multiple | |
51 | canned_test "-L 4,18:a.c -L ^:main:a.c simple" multiple-overlapping | |
52 | canned_test "-L :main:a.c -L 4,18:a.c simple" multiple-overlapping | |
53 | canned_test "-L 4:a.c -L 8,12:a.c simple" multiple-superset | |
54 | canned_test "-L 8,12:a.c -L 4:a.c simple" multiple-superset | |
55 | ||
56 | test_bad_opts "-L" "switch.*requires a value" | |
57 | test_bad_opts "-L b.c" "argument not .start,end:file" | |
58 | test_bad_opts "-L 1:" "argument not .start,end:file" | |
59 | test_bad_opts "-L 1:nonexistent" "There is no path" | |
60 | test_bad_opts "-L 1:simple" "There is no path" | |
61 | test_bad_opts "-L '/foo:b.c'" "argument not .start,end:file" | |
62 | test_bad_opts "-L 1000:b.c" "has only.*lines" | |
63 | test_bad_opts "-L :b.c" "argument not .start,end:file" | |
64 | test_bad_opts "-L :foo:b.c" "no match" | |
65 | ||
66 | test_expect_success '-L X (X == nlines)' ' | |
67 | n=$(wc -l <b.c) && | |
68 | git log -L $n:b.c | |
69 | ' | |
70 | ||
71 | test_expect_success '-L X (X == nlines + 1)' ' | |
72 | n=$(expr $(wc -l <b.c) + 1) && | |
73 | test_must_fail git log -L $n:b.c | |
74 | ' | |
75 | ||
76 | test_expect_success '-L X (X == nlines + 2)' ' | |
77 | n=$(expr $(wc -l <b.c) + 2) && | |
78 | test_must_fail git log -L $n:b.c | |
79 | ' | |
80 | ||
81 | test_expect_success '-L ,Y (Y == nlines)' ' | |
82 | n=$(printf "%d" $(wc -l <b.c)) && | |
83 | git log -L ,$n:b.c | |
84 | ' | |
85 | ||
86 | test_expect_success '-L ,Y (Y == nlines + 1)' ' | |
87 | n=$(expr $(wc -l <b.c) + 1) && | |
88 | git log -L ,$n:b.c | |
89 | ' | |
90 | ||
91 | test_expect_success '-L ,Y (Y == nlines + 2)' ' | |
92 | n=$(expr $(wc -l <b.c) + 2) && | |
93 | git log -L ,$n:b.c | |
94 | ' | |
95 | ||
96 | test_expect_success '-L with --first-parent and a merge' ' | |
97 | git checkout parallel-change && | |
98 | git log --first-parent -L 1,1:b.c | |
99 | ' | |
100 | ||
101 | test_expect_success '-L with --output' ' | |
102 | git checkout parallel-change && | |
103 | git log --output=log -L :main:b.c >output && | |
104 | test_must_be_empty output && | |
105 | test_line_count = 70 log | |
106 | ' | |
107 | ||
108 | test_expect_success 'range_set_union' ' | |
109 | test_seq 500 > c.c && | |
110 | git add c.c && | |
111 | git commit -m "many lines" && | |
112 | test_seq 1000 > c.c && | |
113 | git add c.c && | |
114 | git commit -m "modify many lines" && | |
115 | git log $(for x in $(test_seq 200); do echo -L $((2*x)),+1:c.c; done) | |
116 | ' | |
117 | ||
118 | test_expect_success '-s shows only line-log commits' ' | |
119 | git log --format="commit %s" -L1,24:b.c >expect.raw && | |
120 | grep ^commit expect.raw >expect && | |
121 | git log --format="commit %s" -L1,24:b.c -s >actual && | |
122 | test_cmp expect actual | |
123 | ' | |
124 | ||
125 | test_expect_success '-p shows the default patch output' ' | |
126 | git log -L1,24:b.c >expect && | |
127 | git log -L1,24:b.c -p >actual && | |
128 | test_cmp expect actual | |
129 | ' | |
130 | ||
131 | test_expect_success '--raw is forbidden' ' | |
132 | test_must_fail git log -L1,24:b.c --raw | |
133 | ' | |
134 | ||
135 | test_done |