Blame


1 c970ea82 2019-07-27 stsp #!/bin/sh
2 c970ea82 2019-07-27 stsp #
3 c970ea82 2019-07-27 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 c970ea82 2019-07-27 stsp #
5 c970ea82 2019-07-27 stsp # Permission to use, copy, modify, and distribute this software for any
6 c970ea82 2019-07-27 stsp # purpose with or without fee is hereby granted, provided that the above
7 c970ea82 2019-07-27 stsp # copyright notice and this permission notice appear in all copies.
8 c970ea82 2019-07-27 stsp #
9 c970ea82 2019-07-27 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c970ea82 2019-07-27 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c970ea82 2019-07-27 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c970ea82 2019-07-27 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c970ea82 2019-07-27 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c970ea82 2019-07-27 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c970ea82 2019-07-27 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 c970ea82 2019-07-27 stsp
17 c970ea82 2019-07-27 stsp . ./common.sh
18 c970ea82 2019-07-27 stsp
19 c970ea82 2019-07-27 stsp function test_blame_basic {
20 c970ea82 2019-07-27 stsp local testroot=`test_init blame_basic`
21 c970ea82 2019-07-27 stsp
22 c970ea82 2019-07-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 c970ea82 2019-07-27 stsp ret="$?"
24 c970ea82 2019-07-27 stsp if [ "$ret" != "0" ]; then
25 c970ea82 2019-07-27 stsp test_done "$testroot" "$ret"
26 c970ea82 2019-07-27 stsp return 1
27 c970ea82 2019-07-27 stsp fi
28 c970ea82 2019-07-27 stsp
29 c970ea82 2019-07-27 stsp echo 1 > $testroot/wt/alpha
30 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
31 c970ea82 2019-07-27 stsp local commit1=`git_show_head $testroot/repo`
32 c970ea82 2019-07-27 stsp
33 c970ea82 2019-07-27 stsp echo 2 >> $testroot/wt/alpha
34 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
35 c970ea82 2019-07-27 stsp local commit2=`git_show_head $testroot/repo`
36 c970ea82 2019-07-27 stsp
37 c970ea82 2019-07-27 stsp echo 3 >> $testroot/wt/alpha
38 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
39 c970ea82 2019-07-27 stsp local commit3=`git_show_head $testroot/repo`
40 bcb49d15 2019-08-14 stsp local author_time=`git_show_author_time $testroot/repo`
41 c970ea82 2019-07-27 stsp
42 c970ea82 2019-07-27 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
43 c970ea82 2019-07-27 stsp
44 c970ea82 2019-07-27 stsp local short_commit1=`trim_obj_id 32 $commit1`
45 c970ea82 2019-07-27 stsp local short_commit2=`trim_obj_id 32 $commit2`
46 c970ea82 2019-07-27 stsp local short_commit3=`trim_obj_id 32 $commit3`
47 c970ea82 2019-07-27 stsp
48 bcb49d15 2019-08-14 stsp d=`date -r $author_time +"%g/%m/%d"`
49 bcb49d15 2019-08-14 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
50 bcb49d15 2019-08-14 stsp echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
51 bcb49d15 2019-08-14 stsp echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
52 c970ea82 2019-07-27 stsp
53 c970ea82 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
54 c970ea82 2019-07-27 stsp ret="$?"
55 c970ea82 2019-07-27 stsp if [ "$ret" != "0" ]; then
56 c970ea82 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
57 c970ea82 2019-07-27 stsp fi
58 c970ea82 2019-07-27 stsp
59 c970ea82 2019-07-27 stsp test_done "$testroot" "$ret"
60 c970ea82 2019-07-27 stsp }
61 c970ea82 2019-07-27 stsp
62 303e2782 2019-08-09 stsp function test_blame_tag {
63 303e2782 2019-08-09 stsp local testroot=`test_init blame_tag`
64 303e2782 2019-08-09 stsp local tag=1.0.0
65 303e2782 2019-08-09 stsp
66 303e2782 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
67 303e2782 2019-08-09 stsp ret="$?"
68 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
69 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
70 303e2782 2019-08-09 stsp return 1
71 303e2782 2019-08-09 stsp fi
72 303e2782 2019-08-09 stsp echo 1 > $testroot/wt/alpha
73 303e2782 2019-08-09 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
74 303e2782 2019-08-09 stsp local commit1=`git_show_head $testroot/repo`
75 303e2782 2019-08-09 stsp
76 303e2782 2019-08-09 stsp echo 2 >> $testroot/wt/alpha
77 303e2782 2019-08-09 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
78 303e2782 2019-08-09 stsp local commit2=`git_show_head $testroot/repo`
79 303e2782 2019-08-09 stsp
80 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -a -m "test" $tag)
81 303e2782 2019-08-09 stsp
82 303e2782 2019-08-09 stsp echo 3 >> $testroot/wt/alpha
83 303e2782 2019-08-09 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
84 303e2782 2019-08-09 stsp local commit3=`git_show_head $testroot/repo`
85 bcb49d15 2019-08-14 stsp local author_time=`git_show_author_time $testroot/repo`
86 303e2782 2019-08-09 stsp
87 303e2782 2019-08-09 stsp (cd $testroot/wt && got blame -c $tag alpha > $testroot/stdout)
88 303e2782 2019-08-09 stsp
89 303e2782 2019-08-09 stsp local short_commit1=`trim_obj_id 32 $commit1`
90 303e2782 2019-08-09 stsp local short_commit2=`trim_obj_id 32 $commit2`
91 303e2782 2019-08-09 stsp
92 bcb49d15 2019-08-14 stsp d=`date -r $author_time +"%g/%m/%d"`
93 bcb49d15 2019-08-14 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
94 bcb49d15 2019-08-14 stsp echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
95 303e2782 2019-08-09 stsp
96 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
97 303e2782 2019-08-09 stsp ret="$?"
98 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
99 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
100 303e2782 2019-08-09 stsp fi
101 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
102 303e2782 2019-08-09 stsp }
103 303e2782 2019-08-09 stsp
104 78695fb7 2019-08-12 stsp function test_blame_file_single_line {
105 78695fb7 2019-08-12 stsp local testroot=`test_init blame_file_single_line`
106 78695fb7 2019-08-12 stsp
107 78695fb7 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
108 78695fb7 2019-08-12 stsp ret="$?"
109 78695fb7 2019-08-12 stsp if [ "$ret" != "0" ]; then
110 78695fb7 2019-08-12 stsp test_done "$testroot" "$ret"
111 78695fb7 2019-08-12 stsp return 1
112 78695fb7 2019-08-12 stsp fi
113 78695fb7 2019-08-12 stsp
114 78695fb7 2019-08-12 stsp echo 1 > $testroot/wt/alpha
115 78695fb7 2019-08-12 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
116 78695fb7 2019-08-12 stsp local commit1=`git_show_head $testroot/repo`
117 bcb49d15 2019-08-14 stsp local author_time=`git_show_author_time $testroot/repo`
118 78695fb7 2019-08-12 stsp
119 78695fb7 2019-08-12 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
120 78695fb7 2019-08-12 stsp
121 78695fb7 2019-08-12 stsp local short_commit1=`trim_obj_id 32 $commit1`
122 78695fb7 2019-08-12 stsp
123 bcb49d15 2019-08-14 stsp d=`date -r $author_time +"%g/%m/%d"`
124 bcb49d15 2019-08-14 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
125 78695fb7 2019-08-12 stsp
126 78695fb7 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
127 78695fb7 2019-08-12 stsp ret="$?"
128 78695fb7 2019-08-12 stsp if [ "$ret" != "0" ]; then
129 78695fb7 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
130 78695fb7 2019-08-12 stsp fi
131 78695fb7 2019-08-12 stsp test_done "$testroot" "$ret"
132 78695fb7 2019-08-12 stsp }
133 78695fb7 2019-08-12 stsp
134 78695fb7 2019-08-12 stsp function test_blame_file_single_line_no_newline {
135 78695fb7 2019-08-12 stsp local testroot=`test_init blame_file_single_line_no_newline`
136 78695fb7 2019-08-12 stsp
137 78695fb7 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
138 78695fb7 2019-08-12 stsp ret="$?"
139 78695fb7 2019-08-12 stsp if [ "$ret" != "0" ]; then
140 78695fb7 2019-08-12 stsp test_done "$testroot" "$ret"
141 78695fb7 2019-08-12 stsp return 1
142 78695fb7 2019-08-12 stsp fi
143 78695fb7 2019-08-12 stsp
144 78695fb7 2019-08-12 stsp echo -n 1 > $testroot/wt/alpha
145 78695fb7 2019-08-12 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
146 78695fb7 2019-08-12 stsp local commit1=`git_show_head $testroot/repo`
147 bcb49d15 2019-08-14 stsp local author_time=`git_show_author_time $testroot/repo`
148 78695fb7 2019-08-12 stsp
149 78695fb7 2019-08-12 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
150 78695fb7 2019-08-12 stsp
151 78695fb7 2019-08-12 stsp local short_commit1=`trim_obj_id 32 $commit1`
152 78695fb7 2019-08-12 stsp
153 bcb49d15 2019-08-14 stsp d=`date -r $author_time +"%g/%m/%d"`
154 bcb49d15 2019-08-14 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
155 78695fb7 2019-08-12 stsp
156 78695fb7 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
157 78695fb7 2019-08-12 stsp ret="$?"
158 78695fb7 2019-08-12 stsp if [ "$ret" != "0" ]; then
159 78695fb7 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
160 78695fb7 2019-08-12 stsp fi
161 78695fb7 2019-08-12 stsp test_done "$testroot" "$ret"
162 78695fb7 2019-08-12 stsp }
163 78695fb7 2019-08-12 stsp
164 8d725ae1 2019-08-18 stsp function test_blame_all_lines_replaced {
165 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_all_lines_replaced`
166 8d725ae1 2019-08-18 stsp
167 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
168 8d725ae1 2019-08-18 stsp ret="$?"
169 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
170 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
171 8d725ae1 2019-08-18 stsp return 1
172 8d725ae1 2019-08-18 stsp fi
173 8d725ae1 2019-08-18 stsp
174 8d725ae1 2019-08-18 stsp jot 8 > $testroot/wt/alpha
175 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
176 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
177 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
178 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
179 8d725ae1 2019-08-18 stsp
180 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
181 8d725ae1 2019-08-18 stsp
182 8d725ae1 2019-08-18 stsp d=`date -r $author_time +"%g/%m/%d"`
183 8d725ae1 2019-08-18 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
184 8d725ae1 2019-08-18 stsp echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
185 8d725ae1 2019-08-18 stsp echo "3) $short_commit1 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
186 8d725ae1 2019-08-18 stsp echo "4) $short_commit1 $d $GOT_AUTHOR_8 4" >> $testroot/stdout.expected
187 8d725ae1 2019-08-18 stsp echo "5) $short_commit1 $d $GOT_AUTHOR_8 5" >> $testroot/stdout.expected
188 8d725ae1 2019-08-18 stsp echo "6) $short_commit1 $d $GOT_AUTHOR_8 6" >> $testroot/stdout.expected
189 8d725ae1 2019-08-18 stsp echo "7) $short_commit1 $d $GOT_AUTHOR_8 7" >> $testroot/stdout.expected
190 8d725ae1 2019-08-18 stsp echo "8) $short_commit1 $d $GOT_AUTHOR_8 8" >> $testroot/stdout.expected
191 8d725ae1 2019-08-18 stsp
192 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
193 8d725ae1 2019-08-18 stsp ret="$?"
194 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
195 8d725ae1 2019-08-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
196 8d725ae1 2019-08-18 stsp fi
197 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
198 8d725ae1 2019-08-18 stsp
199 8d725ae1 2019-08-18 stsp }
200 8d725ae1 2019-08-18 stsp
201 8d725ae1 2019-08-18 stsp function test_blame_lines_shifted_up {
202 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_lines_shifted_up`
203 8d725ae1 2019-08-18 stsp
204 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
205 8d725ae1 2019-08-18 stsp ret="$?"
206 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
207 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
208 8d725ae1 2019-08-18 stsp return 1
209 8d725ae1 2019-08-18 stsp fi
210 8d725ae1 2019-08-18 stsp
211 8d725ae1 2019-08-18 stsp jot 8 > $testroot/wt/alpha
212 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
213 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
214 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
215 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
216 8d725ae1 2019-08-18 stsp
217 8d725ae1 2019-08-18 stsp sed -i -e '/^[345]$/d' $testroot/wt/alpha
218 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
219 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
220 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
221 8d725ae1 2019-08-18 stsp
222 8d725ae1 2019-08-18 stsp jot 2 > $testroot/wt/alpha
223 8d725ae1 2019-08-18 stsp echo foo >> $testroot/wt/alpha
224 8d725ae1 2019-08-18 stsp echo bar >> $testroot/wt/alpha
225 8d725ae1 2019-08-18 stsp echo baz >> $testroot/wt/alpha
226 8d725ae1 2019-08-18 stsp jot 8 6 8 1 >> $testroot/wt/alpha
227 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
228 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
229 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
230 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
231 8d725ae1 2019-08-18 stsp
232 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
233 8d725ae1 2019-08-18 stsp
234 8d725ae1 2019-08-18 stsp d=`date -r $author_time +"%g/%m/%d"`
235 8d725ae1 2019-08-18 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
236 8d725ae1 2019-08-18 stsp echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
237 8d725ae1 2019-08-18 stsp echo "3) $short_commit3 $d $GOT_AUTHOR_8 foo" >> $testroot/stdout.expected
238 8d725ae1 2019-08-18 stsp echo "4) $short_commit3 $d $GOT_AUTHOR_8 bar" >> $testroot/stdout.expected
239 8d725ae1 2019-08-18 stsp echo "5) $short_commit3 $d $GOT_AUTHOR_8 baz" >> $testroot/stdout.expected
240 8d725ae1 2019-08-18 stsp echo "6) $short_commit1 $d $GOT_AUTHOR_8 6" >> $testroot/stdout.expected
241 8d725ae1 2019-08-18 stsp echo "7) $short_commit1 $d $GOT_AUTHOR_8 7" >> $testroot/stdout.expected
242 8d725ae1 2019-08-18 stsp echo "8) $short_commit1 $d $GOT_AUTHOR_8 8" >> $testroot/stdout.expected
243 8d725ae1 2019-08-18 stsp
244 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
245 8d725ae1 2019-08-18 stsp ret="$?"
246 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
247 8d725ae1 2019-08-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
248 8d725ae1 2019-08-18 stsp fi
249 8d725ae1 2019-08-18 stsp
250 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
251 8d725ae1 2019-08-18 stsp }
252 8d725ae1 2019-08-18 stsp
253 8d725ae1 2019-08-18 stsp function test_blame_lines_shifted_down {
254 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_lines_shifted_down`
255 8d725ae1 2019-08-18 stsp
256 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
257 8d725ae1 2019-08-18 stsp ret="$?"
258 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
259 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
260 8d725ae1 2019-08-18 stsp return 1
261 8d725ae1 2019-08-18 stsp fi
262 8d725ae1 2019-08-18 stsp
263 8d725ae1 2019-08-18 stsp jot 8 > $testroot/wt/alpha
264 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
265 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
266 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
267 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
268 8d725ae1 2019-08-18 stsp
269 8d725ae1 2019-08-18 stsp sed -i -e '/^8$/d' $testroot/wt/alpha
270 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
271 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
272 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
273 8d725ae1 2019-08-18 stsp
274 8d725ae1 2019-08-18 stsp jot 2 > $testroot/wt/alpha
275 8d725ae1 2019-08-18 stsp echo foo >> $testroot/wt/alpha
276 8d725ae1 2019-08-18 stsp echo bar >> $testroot/wt/alpha
277 8d725ae1 2019-08-18 stsp echo baz >> $testroot/wt/alpha
278 8d725ae1 2019-08-18 stsp jot 8 3 8 1 >> $testroot/wt/alpha
279 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
280 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
281 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
282 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
283 8d725ae1 2019-08-18 stsp
284 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
285 8d725ae1 2019-08-18 stsp
286 8d725ae1 2019-08-18 stsp d=`date -r $author_time +"%g/%m/%d"`
287 8d725ae1 2019-08-18 stsp echo "01) $short_commit1 $d $GOT_AUTHOR_8 1" \
288 8d725ae1 2019-08-18 stsp > $testroot/stdout.expected
289 8d725ae1 2019-08-18 stsp echo "02) $short_commit1 $d $GOT_AUTHOR_8 2" \
290 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
291 8d725ae1 2019-08-18 stsp echo "03) $short_commit3 $d $GOT_AUTHOR_8 foo" \
292 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
293 8d725ae1 2019-08-18 stsp echo "04) $short_commit3 $d $GOT_AUTHOR_8 bar" \
294 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
295 8d725ae1 2019-08-18 stsp echo "05) $short_commit3 $d $GOT_AUTHOR_8 baz" \
296 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
297 8d725ae1 2019-08-18 stsp echo "06) $short_commit1 $d $GOT_AUTHOR_8 3" \
298 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
299 8d725ae1 2019-08-18 stsp echo "07) $short_commit1 $d $GOT_AUTHOR_8 4" \
300 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
301 8d725ae1 2019-08-18 stsp echo "08) $short_commit1 $d $GOT_AUTHOR_8 5" \
302 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
303 8d725ae1 2019-08-18 stsp echo "09) $short_commit1 $d $GOT_AUTHOR_8 6" \
304 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
305 8d725ae1 2019-08-18 stsp echo "10) $short_commit1 $d $GOT_AUTHOR_8 7" \
306 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
307 8d725ae1 2019-08-18 stsp echo "11) $short_commit3 $d $GOT_AUTHOR_8 8" \
308 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
309 8d725ae1 2019-08-18 stsp
310 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
311 8d725ae1 2019-08-18 stsp ret="$?"
312 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
313 8d725ae1 2019-08-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
314 8d725ae1 2019-08-18 stsp fi
315 8d725ae1 2019-08-18 stsp
316 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
317 8d725ae1 2019-08-18 stsp }
318 8d725ae1 2019-08-18 stsp
319 8d725ae1 2019-08-18 stsp function test_blame_commit_subsumed {
320 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_commit_subsumed`
321 8d725ae1 2019-08-18 stsp
322 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
323 8d725ae1 2019-08-18 stsp ret="$?"
324 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
325 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
326 8d725ae1 2019-08-18 stsp return 1
327 8d725ae1 2019-08-18 stsp fi
328 8d725ae1 2019-08-18 stsp
329 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
330 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules codedocs docs
331 8d725ae1 2019-08-18 stsp
332 8d725ae1 2019-08-18 stsp if WITH_PDNS_SERVER
333 8d725ae1 2019-08-18 stsp SUBDIRS += pdns
334 8d725ae1 2019-08-18 stsp endif
335 8d725ae1 2019-08-18 stsp
336 8d725ae1 2019-08-18 stsp EXTRA_DIST =
337 8d725ae1 2019-08-18 stsp INSTALL
338 8d725ae1 2019-08-18 stsp NOTICE
339 8d725ae1 2019-08-18 stsp README
340 8d725ae1 2019-08-18 stsp .version
341 8d725ae1 2019-08-18 stsp build-aux/gen-version
342 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
343 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
344 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
345 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
346 8d725ae1 2019-08-18 stsp
347 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
348 8d725ae1 2019-08-18 stsp
349 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
350 8d725ae1 2019-08-18 stsp EOF
351 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
352 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
353 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
354 8d725ae1 2019-08-18 stsp local author_time1=`git_show_author_time $testroot/repo`
355 8d725ae1 2019-08-18 stsp local d1=`date -r $author_time1 +"%g/%m/%d"`
356 8d725ae1 2019-08-18 stsp
357 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
358 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules codedocs docs
359 8d725ae1 2019-08-18 stsp
360 8d725ae1 2019-08-18 stsp SUBDIRS += pdns
361 8d725ae1 2019-08-18 stsp
362 8d725ae1 2019-08-18 stsp EXTRA_DIST =
363 8d725ae1 2019-08-18 stsp INSTALL
364 8d725ae1 2019-08-18 stsp NOTICE
365 8d725ae1 2019-08-18 stsp README
366 8d725ae1 2019-08-18 stsp .version
367 8d725ae1 2019-08-18 stsp build-aux/gen-version
368 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
369 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
370 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
371 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
372 8d725ae1 2019-08-18 stsp
373 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
374 8d725ae1 2019-08-18 stsp
375 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
376 8d725ae1 2019-08-18 stsp EOF
377 8d725ae1 2019-08-18 stsp # all changes in this commit will be subsumed by later commits
378 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
379 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
380 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
381 8d725ae1 2019-08-18 stsp local author_time2=`git_show_author_time $testroot/repo`
382 8d725ae1 2019-08-18 stsp local d2=`date -r $author_time2 +"%g/%m/%d"`
383 8d725ae1 2019-08-18 stsp
384 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
385 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules pdns codedocs docs
386 8d725ae1 2019-08-18 stsp
387 8d725ae1 2019-08-18 stsp EXTRA_DIST =
388 8d725ae1 2019-08-18 stsp INSTALL
389 8d725ae1 2019-08-18 stsp NOTICE
390 8d725ae1 2019-08-18 stsp README
391 8d725ae1 2019-08-18 stsp .version
392 8d725ae1 2019-08-18 stsp build-aux/gen-version
393 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
394 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
395 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
396 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
397 8d725ae1 2019-08-18 stsp
398 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
399 8d725ae1 2019-08-18 stsp
400 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
401 8d725ae1 2019-08-18 stsp EOF
402 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
403 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
404 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
405 8d725ae1 2019-08-18 stsp local author_time3=`git_show_author_time $testroot/repo`
406 8d725ae1 2019-08-18 stsp local d3=`date -r $author_time3 +"%g/%m/%d"`
407 8d725ae1 2019-08-18 stsp
408 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
409 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules pdns codedocs docs
410 8d725ae1 2019-08-18 stsp
411 8d725ae1 2019-08-18 stsp EXTRA_DIST =
412 8d725ae1 2019-08-18 stsp INSTALL
413 8d725ae1 2019-08-18 stsp NOTICE
414 8d725ae1 2019-08-18 stsp README
415 8d725ae1 2019-08-18 stsp COPYING
416 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
417 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
418 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
419 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
420 8d725ae1 2019-08-18 stsp builder-support/gen-version
421 8d725ae1 2019-08-18 stsp
422 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
423 8d725ae1 2019-08-18 stsp
424 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
425 8d725ae1 2019-08-18 stsp EOF
426 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 4" > /dev/null)
427 8d725ae1 2019-08-18 stsp local commit4=`git_show_head $testroot/repo`
428 8d725ae1 2019-08-18 stsp local short_commit4=`trim_obj_id 32 $commit4`
429 8d725ae1 2019-08-18 stsp local author_time4=`git_show_author_time $testroot/repo`
430 8d725ae1 2019-08-18 stsp local d4=`date -r $author_time4 +"%g/%m/%d"`
431 8d725ae1 2019-08-18 stsp
432 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
433 8d725ae1 2019-08-18 stsp
434 8d725ae1 2019-08-18 stsp echo -n "01) $short_commit3 $d3 $GOT_AUTHOR_8 " \
435 8d725ae1 2019-08-18 stsp > $testroot/stdout.expected
436 8d725ae1 2019-08-18 stsp echo "SUBDIRS = ext modules pdns codedocs docs" \
437 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
438 8d725ae1 2019-08-18 stsp echo "02) $short_commit1 $d1 $GOT_AUTHOR_8 " \
439 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
440 8d725ae1 2019-08-18 stsp echo -n "03) $short_commit1 $d1 $GOT_AUTHOR_8 " \
441 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
442 8d725ae1 2019-08-18 stsp echo 'EXTRA_DIST =' >> $testroot/stdout.expected
443 8d725ae1 2019-08-18 stsp echo -n "04) $short_commit1 $d1 $GOT_AUTHOR_8 " \
444 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
445 8d725ae1 2019-08-18 stsp printf "\tINSTALL\n" >> $testroot/stdout.expected
446 8d725ae1 2019-08-18 stsp echo -n "05) $short_commit1 $d1 $GOT_AUTHOR_8 " \
447 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
448 8d725ae1 2019-08-18 stsp printf "\tNOTICE\n" >> $testroot/stdout.expected
449 8d725ae1 2019-08-18 stsp echo -n "06) $short_commit1 $d1 $GOT_AUTHOR_8 " \
450 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
451 8d725ae1 2019-08-18 stsp printf "\tREADME\n" >> $testroot/stdout.expected
452 8d725ae1 2019-08-18 stsp echo -n "07) $short_commit4 $d4 $GOT_AUTHOR_8 " \
453 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
454 8d725ae1 2019-08-18 stsp printf "\tCOPYING\n" >> $testroot/stdout.expected
455 8d725ae1 2019-08-18 stsp echo -n "08) $short_commit1 $d1 $GOT_AUTHOR_8 " \
456 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
457 8d725ae1 2019-08-18 stsp printf "\tcodedocs/doxygen.conf\n" >> $testroot/stdout.expected
458 8d725ae1 2019-08-18 stsp echo -n "09) $short_commit1 $d1 $GOT_AUTHOR_8 " \
459 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
460 8d725ae1 2019-08-18 stsp printf "\tcontrib/powerdns.solaris.init.d\n" \
461 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
462 8d725ae1 2019-08-18 stsp echo -n "10) $short_commit1 $d1 $GOT_AUTHOR_8 " \
463 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
464 8d725ae1 2019-08-18 stsp printf "\tpdns/named.conf.parsertest\n" >> $testroot/stdout.expected
465 8d725ae1 2019-08-18 stsp echo -n "11) $short_commit1 $d1 $GOT_AUTHOR_8 " \
466 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
467 8d725ae1 2019-08-18 stsp printf "\tregression-tests/zones/unit.test\n" \
468 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
469 8d725ae1 2019-08-18 stsp echo -n "12) $short_commit4 $d4 $GOT_AUTHOR_8 " \
470 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
471 8d725ae1 2019-08-18 stsp printf "\tbuilder-support/gen-version\n" >> $testroot/stdout.expected
472 8d725ae1 2019-08-18 stsp echo "13) $short_commit1 $d1 $GOT_AUTHOR_8 " \
473 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
474 8d725ae1 2019-08-18 stsp echo -n "14) $short_commit1 $d1 $GOT_AUTHOR_8 " \
475 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
476 8d725ae1 2019-08-18 stsp echo "ACLOCAL_AMFLAGS = -I m4" \
477 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
478 8d725ae1 2019-08-18 stsp echo "15) $short_commit1 $d1 $GOT_AUTHOR_8 " \
479 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
480 8d725ae1 2019-08-18 stsp echo -n "16) $short_commit1 $d1 $GOT_AUTHOR_8 " \
481 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
482 8d725ae1 2019-08-18 stsp echo "dvi: # do nothing to build dvi" \
483 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
484 8d725ae1 2019-08-18 stsp
485 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
486 8d725ae1 2019-08-18 stsp ret="$?"
487 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
488 548237bc 2019-08-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
489 548237bc 2019-08-19 stsp test_done "$testroot" "$ret"
490 8d725ae1 2019-08-18 stsp return 1
491 8d725ae1 2019-08-18 stsp fi
492 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
493 8d725ae1 2019-08-18 stsp }
494 8d725ae1 2019-08-18 stsp
495 c970ea82 2019-07-27 stsp run_test test_blame_basic
496 303e2782 2019-08-09 stsp run_test test_blame_tag
497 78695fb7 2019-08-12 stsp run_test test_blame_file_single_line
498 78695fb7 2019-08-12 stsp run_test test_blame_file_single_line_no_newline
499 8d725ae1 2019-08-18 stsp run_test test_blame_all_lines_replaced
500 8d725ae1 2019-08-18 stsp run_test test_blame_lines_shifted_up
501 8d725ae1 2019-08-18 stsp run_test test_blame_lines_shifted_down
502 8d725ae1 2019-08-18 stsp run_test test_blame_commit_subsumed