3 c970ea82 2019-07-27 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 c970ea82 2019-07-27 stsp . ./common.sh
19 b24db1c1 2019-08-19 stsp function blame_cmp {
20 b24db1c1 2019-08-19 stsp local testroot="$1"
21 b24db1c1 2019-08-19 stsp local file="$2"
22 16357e96 2019-08-19 stsp local xfail="$3"
24 b24db1c1 2019-08-19 stsp (cd $testroot/wt && got blame "$file" | cut -d ' ' -f 2 \
25 b24db1c1 2019-08-19 stsp > $testroot/${file}.blame.got)
26 b24db1c1 2019-08-19 stsp (cd $testroot/repo && git reset --hard master > /dev/null)
27 b24db1c1 2019-08-19 stsp (cd $testroot/repo && git blame "$file" | cut -d ' ' -f 1 \
28 b24db1c1 2019-08-19 stsp > $testroot/${file}.blame.git)
30 b24db1c1 2019-08-19 stsp cmp -s $testroot/${file}.blame.git $testroot/${file}.blame.got
32 16357e96 2019-08-19 stsp if [ "$ret" != "0" -a "$xfail" == "" ]; then
33 b24db1c1 2019-08-19 stsp diff -u $testroot/${file}.blame.git $testroot/${file}.blame.got
36 16357e96 2019-08-19 stsp return "$ret"
39 c970ea82 2019-07-27 stsp function test_blame_basic {
40 c970ea82 2019-07-27 stsp local testroot=`test_init blame_basic`
42 c970ea82 2019-07-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
44 c970ea82 2019-07-27 stsp if [ "$ret" != "0" ]; then
45 c970ea82 2019-07-27 stsp test_done "$testroot" "$ret"
49 c970ea82 2019-07-27 stsp echo 1 > $testroot/wt/alpha
50 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
51 c970ea82 2019-07-27 stsp local commit1=`git_show_head $testroot/repo`
53 c970ea82 2019-07-27 stsp echo 2 >> $testroot/wt/alpha
54 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
55 c970ea82 2019-07-27 stsp local commit2=`git_show_head $testroot/repo`
57 c970ea82 2019-07-27 stsp echo 3 >> $testroot/wt/alpha
58 c970ea82 2019-07-27 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
59 c970ea82 2019-07-27 stsp local commit3=`git_show_head $testroot/repo`
60 bcb49d15 2019-08-14 stsp local author_time=`git_show_author_time $testroot/repo`
62 c970ea82 2019-07-27 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
64 c970ea82 2019-07-27 stsp local short_commit1=`trim_obj_id 32 $commit1`
65 c970ea82 2019-07-27 stsp local short_commit2=`trim_obj_id 32 $commit2`
66 c970ea82 2019-07-27 stsp local short_commit3=`trim_obj_id 32 $commit3`
68 bcb49d15 2019-08-14 stsp d=`date -r $author_time +"%g/%m/%d"`
69 bcb49d15 2019-08-14 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
70 bcb49d15 2019-08-14 stsp echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
71 bcb49d15 2019-08-14 stsp echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
73 c970ea82 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
75 c970ea82 2019-07-27 stsp if [ "$ret" != "0" ]; then
76 c970ea82 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
77 b24db1c1 2019-08-19 stsp test_done "$testroot" "$ret"
81 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
83 c970ea82 2019-07-27 stsp test_done "$testroot" "$ret"
86 303e2782 2019-08-09 stsp function test_blame_tag {
87 303e2782 2019-08-09 stsp local testroot=`test_init blame_tag`
88 303e2782 2019-08-09 stsp local tag=1.0.0
90 303e2782 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
92 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
93 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
96 303e2782 2019-08-09 stsp echo 1 > $testroot/wt/alpha
97 303e2782 2019-08-09 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
98 303e2782 2019-08-09 stsp local commit1=`git_show_head $testroot/repo`
100 303e2782 2019-08-09 stsp echo 2 >> $testroot/wt/alpha
101 303e2782 2019-08-09 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
102 303e2782 2019-08-09 stsp local commit2=`git_show_head $testroot/repo`
104 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -a -m "test" $tag)
106 303e2782 2019-08-09 stsp echo 3 >> $testroot/wt/alpha
107 303e2782 2019-08-09 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
108 303e2782 2019-08-09 stsp local commit3=`git_show_head $testroot/repo`
109 bcb49d15 2019-08-14 stsp local author_time=`git_show_author_time $testroot/repo`
111 303e2782 2019-08-09 stsp (cd $testroot/wt && got blame -c $tag alpha > $testroot/stdout)
113 303e2782 2019-08-09 stsp local short_commit1=`trim_obj_id 32 $commit1`
114 303e2782 2019-08-09 stsp local short_commit2=`trim_obj_id 32 $commit2`
116 bcb49d15 2019-08-14 stsp d=`date -r $author_time +"%g/%m/%d"`
117 bcb49d15 2019-08-14 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
118 bcb49d15 2019-08-14 stsp echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
120 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
122 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
123 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
124 b24db1c1 2019-08-19 stsp test_done "$testroot" "$ret"
128 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
130 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
133 78695fb7 2019-08-12 stsp function test_blame_file_single_line {
134 78695fb7 2019-08-12 stsp local testroot=`test_init blame_file_single_line`
136 78695fb7 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
138 78695fb7 2019-08-12 stsp if [ "$ret" != "0" ]; then
139 78695fb7 2019-08-12 stsp test_done "$testroot" "$ret"
143 78695fb7 2019-08-12 stsp echo 1 > $testroot/wt/alpha
144 78695fb7 2019-08-12 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
145 78695fb7 2019-08-12 stsp local commit1=`git_show_head $testroot/repo`
146 bcb49d15 2019-08-14 stsp local author_time=`git_show_author_time $testroot/repo`
148 78695fb7 2019-08-12 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
150 78695fb7 2019-08-12 stsp local short_commit1=`trim_obj_id 32 $commit1`
152 bcb49d15 2019-08-14 stsp d=`date -r $author_time +"%g/%m/%d"`
153 bcb49d15 2019-08-14 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
155 78695fb7 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
157 78695fb7 2019-08-12 stsp if [ "$ret" != "0" ]; then
158 78695fb7 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
159 b24db1c1 2019-08-19 stsp test_done "$testroot" "$ret"
163 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
165 78695fb7 2019-08-12 stsp test_done "$testroot" "$ret"
168 78695fb7 2019-08-12 stsp function test_blame_file_single_line_no_newline {
169 78695fb7 2019-08-12 stsp local testroot=`test_init blame_file_single_line_no_newline`
171 78695fb7 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
173 78695fb7 2019-08-12 stsp if [ "$ret" != "0" ]; then
174 78695fb7 2019-08-12 stsp test_done "$testroot" "$ret"
178 78695fb7 2019-08-12 stsp echo -n 1 > $testroot/wt/alpha
179 78695fb7 2019-08-12 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
180 78695fb7 2019-08-12 stsp local commit1=`git_show_head $testroot/repo`
181 bcb49d15 2019-08-14 stsp local author_time=`git_show_author_time $testroot/repo`
183 78695fb7 2019-08-12 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
185 78695fb7 2019-08-12 stsp local short_commit1=`trim_obj_id 32 $commit1`
187 bcb49d15 2019-08-14 stsp d=`date -r $author_time +"%g/%m/%d"`
188 bcb49d15 2019-08-14 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
190 78695fb7 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
192 78695fb7 2019-08-12 stsp if [ "$ret" != "0" ]; then
193 78695fb7 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
195 78695fb7 2019-08-12 stsp test_done "$testroot" "$ret"
198 8d725ae1 2019-08-18 stsp function test_blame_all_lines_replaced {
199 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_all_lines_replaced`
201 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
203 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
204 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
208 8d725ae1 2019-08-18 stsp jot 8 > $testroot/wt/alpha
209 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
210 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
211 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
212 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
214 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
216 8d725ae1 2019-08-18 stsp d=`date -r $author_time +"%g/%m/%d"`
217 8d725ae1 2019-08-18 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
218 8d725ae1 2019-08-18 stsp echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
219 8d725ae1 2019-08-18 stsp echo "3) $short_commit1 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
220 8d725ae1 2019-08-18 stsp echo "4) $short_commit1 $d $GOT_AUTHOR_8 4" >> $testroot/stdout.expected
221 8d725ae1 2019-08-18 stsp echo "5) $short_commit1 $d $GOT_AUTHOR_8 5" >> $testroot/stdout.expected
222 8d725ae1 2019-08-18 stsp echo "6) $short_commit1 $d $GOT_AUTHOR_8 6" >> $testroot/stdout.expected
223 8d725ae1 2019-08-18 stsp echo "7) $short_commit1 $d $GOT_AUTHOR_8 7" >> $testroot/stdout.expected
224 8d725ae1 2019-08-18 stsp echo "8) $short_commit1 $d $GOT_AUTHOR_8 8" >> $testroot/stdout.expected
226 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
228 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
229 8d725ae1 2019-08-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
231 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
235 8d725ae1 2019-08-18 stsp function test_blame_lines_shifted_up {
236 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_lines_shifted_up`
238 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
240 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
241 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
245 8d725ae1 2019-08-18 stsp jot 8 > $testroot/wt/alpha
246 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
247 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
248 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
249 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
251 8d725ae1 2019-08-18 stsp sed -i -e '/^[345]$/d' $testroot/wt/alpha
252 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
253 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
254 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
256 8d725ae1 2019-08-18 stsp jot 2 > $testroot/wt/alpha
257 8d725ae1 2019-08-18 stsp echo foo >> $testroot/wt/alpha
258 8d725ae1 2019-08-18 stsp echo bar >> $testroot/wt/alpha
259 8d725ae1 2019-08-18 stsp echo baz >> $testroot/wt/alpha
260 8d725ae1 2019-08-18 stsp jot 8 6 8 1 >> $testroot/wt/alpha
261 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
262 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
263 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
264 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
266 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
268 8d725ae1 2019-08-18 stsp d=`date -r $author_time +"%g/%m/%d"`
269 8d725ae1 2019-08-18 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
270 8d725ae1 2019-08-18 stsp echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
271 8d725ae1 2019-08-18 stsp echo "3) $short_commit3 $d $GOT_AUTHOR_8 foo" >> $testroot/stdout.expected
272 8d725ae1 2019-08-18 stsp echo "4) $short_commit3 $d $GOT_AUTHOR_8 bar" >> $testroot/stdout.expected
273 8d725ae1 2019-08-18 stsp echo "5) $short_commit3 $d $GOT_AUTHOR_8 baz" >> $testroot/stdout.expected
274 8d725ae1 2019-08-18 stsp echo "6) $short_commit1 $d $GOT_AUTHOR_8 6" >> $testroot/stdout.expected
275 8d725ae1 2019-08-18 stsp echo "7) $short_commit1 $d $GOT_AUTHOR_8 7" >> $testroot/stdout.expected
276 8d725ae1 2019-08-18 stsp echo "8) $short_commit1 $d $GOT_AUTHOR_8 8" >> $testroot/stdout.expected
278 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
280 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
281 8d725ae1 2019-08-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
282 b24db1c1 2019-08-19 stsp test_done "$testroot" "$ret"
286 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
288 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
291 8d725ae1 2019-08-18 stsp function test_blame_lines_shifted_down {
292 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_lines_shifted_down`
294 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
296 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
297 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
301 8d725ae1 2019-08-18 stsp jot 8 > $testroot/wt/alpha
302 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
303 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
304 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
305 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
307 8d725ae1 2019-08-18 stsp sed -i -e '/^8$/d' $testroot/wt/alpha
308 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
309 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
310 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
312 8d725ae1 2019-08-18 stsp jot 2 > $testroot/wt/alpha
313 8d725ae1 2019-08-18 stsp echo foo >> $testroot/wt/alpha
314 8d725ae1 2019-08-18 stsp echo bar >> $testroot/wt/alpha
315 8d725ae1 2019-08-18 stsp echo baz >> $testroot/wt/alpha
316 8d725ae1 2019-08-18 stsp jot 8 3 8 1 >> $testroot/wt/alpha
317 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
318 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
319 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
320 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
322 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
324 8d725ae1 2019-08-18 stsp d=`date -r $author_time +"%g/%m/%d"`
325 8d725ae1 2019-08-18 stsp echo "01) $short_commit1 $d $GOT_AUTHOR_8 1" \
326 8d725ae1 2019-08-18 stsp > $testroot/stdout.expected
327 8d725ae1 2019-08-18 stsp echo "02) $short_commit1 $d $GOT_AUTHOR_8 2" \
328 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
329 8d725ae1 2019-08-18 stsp echo "03) $short_commit3 $d $GOT_AUTHOR_8 foo" \
330 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
331 8d725ae1 2019-08-18 stsp echo "04) $short_commit3 $d $GOT_AUTHOR_8 bar" \
332 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
333 8d725ae1 2019-08-18 stsp echo "05) $short_commit3 $d $GOT_AUTHOR_8 baz" \
334 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
335 8d725ae1 2019-08-18 stsp echo "06) $short_commit1 $d $GOT_AUTHOR_8 3" \
336 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
337 8d725ae1 2019-08-18 stsp echo "07) $short_commit1 $d $GOT_AUTHOR_8 4" \
338 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
339 8d725ae1 2019-08-18 stsp echo "08) $short_commit1 $d $GOT_AUTHOR_8 5" \
340 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
341 8d725ae1 2019-08-18 stsp echo "09) $short_commit1 $d $GOT_AUTHOR_8 6" \
342 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
343 8d725ae1 2019-08-18 stsp echo "10) $short_commit1 $d $GOT_AUTHOR_8 7" \
344 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
345 8d725ae1 2019-08-18 stsp echo "11) $short_commit3 $d $GOT_AUTHOR_8 8" \
346 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
348 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
350 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
351 8d725ae1 2019-08-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
352 b24db1c1 2019-08-19 stsp test_done "$testroot" "$ret"
356 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
358 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
361 8d725ae1 2019-08-18 stsp function test_blame_commit_subsumed {
362 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_commit_subsumed`
364 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
366 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
367 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
371 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
372 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules codedocs docs
374 8d725ae1 2019-08-18 stsp if WITH_PDNS_SERVER
375 8d725ae1 2019-08-18 stsp SUBDIRS += pdns
378 8d725ae1 2019-08-18 stsp EXTRA_DIST =
383 8d725ae1 2019-08-18 stsp build-aux/gen-version
384 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
385 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
386 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
387 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
389 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
391 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
393 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
394 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
395 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
396 8d725ae1 2019-08-18 stsp local author_time1=`git_show_author_time $testroot/repo`
397 8d725ae1 2019-08-18 stsp local d1=`date -r $author_time1 +"%g/%m/%d"`
399 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
400 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules codedocs docs
402 8d725ae1 2019-08-18 stsp SUBDIRS += pdns
404 8d725ae1 2019-08-18 stsp EXTRA_DIST =
409 8d725ae1 2019-08-18 stsp build-aux/gen-version
410 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
411 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
412 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
413 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
415 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
417 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
419 8d725ae1 2019-08-18 stsp # all changes in this commit will be subsumed by later commits
420 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
421 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
422 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
423 8d725ae1 2019-08-18 stsp local author_time2=`git_show_author_time $testroot/repo`
424 8d725ae1 2019-08-18 stsp local d2=`date -r $author_time2 +"%g/%m/%d"`
426 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
427 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules pdns codedocs docs
429 8d725ae1 2019-08-18 stsp EXTRA_DIST =
434 8d725ae1 2019-08-18 stsp build-aux/gen-version
435 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
436 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
437 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
438 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
440 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
442 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
444 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
445 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
446 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
447 8d725ae1 2019-08-18 stsp local author_time3=`git_show_author_time $testroot/repo`
448 8d725ae1 2019-08-18 stsp local d3=`date -r $author_time3 +"%g/%m/%d"`
450 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
451 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules pdns codedocs docs
453 8d725ae1 2019-08-18 stsp EXTRA_DIST =
458 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
459 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
460 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
461 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
462 8d725ae1 2019-08-18 stsp builder-support/gen-version
464 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
466 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
468 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 4" > /dev/null)
469 8d725ae1 2019-08-18 stsp local commit4=`git_show_head $testroot/repo`
470 8d725ae1 2019-08-18 stsp local short_commit4=`trim_obj_id 32 $commit4`
471 8d725ae1 2019-08-18 stsp local author_time4=`git_show_author_time $testroot/repo`
472 8d725ae1 2019-08-18 stsp local d4=`date -r $author_time4 +"%g/%m/%d"`
474 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
476 8d725ae1 2019-08-18 stsp echo -n "01) $short_commit3 $d3 $GOT_AUTHOR_8 " \
477 8d725ae1 2019-08-18 stsp > $testroot/stdout.expected
478 8d725ae1 2019-08-18 stsp echo "SUBDIRS = ext modules pdns codedocs docs" \
479 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
480 8d725ae1 2019-08-18 stsp echo "02) $short_commit1 $d1 $GOT_AUTHOR_8 " \
481 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
482 8d725ae1 2019-08-18 stsp echo -n "03) $short_commit1 $d1 $GOT_AUTHOR_8 " \
483 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
484 8d725ae1 2019-08-18 stsp echo 'EXTRA_DIST =' >> $testroot/stdout.expected
485 8d725ae1 2019-08-18 stsp echo -n "04) $short_commit1 $d1 $GOT_AUTHOR_8 " \
486 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
487 8d725ae1 2019-08-18 stsp printf "\tINSTALL\n" >> $testroot/stdout.expected
488 8d725ae1 2019-08-18 stsp echo -n "05) $short_commit1 $d1 $GOT_AUTHOR_8 " \
489 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
490 8d725ae1 2019-08-18 stsp printf "\tNOTICE\n" >> $testroot/stdout.expected
491 8d725ae1 2019-08-18 stsp echo -n "06) $short_commit1 $d1 $GOT_AUTHOR_8 " \
492 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
493 8d725ae1 2019-08-18 stsp printf "\tREADME\n" >> $testroot/stdout.expected
494 8d725ae1 2019-08-18 stsp echo -n "07) $short_commit4 $d4 $GOT_AUTHOR_8 " \
495 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
496 8d725ae1 2019-08-18 stsp printf "\tCOPYING\n" >> $testroot/stdout.expected
497 8d725ae1 2019-08-18 stsp echo -n "08) $short_commit1 $d1 $GOT_AUTHOR_8 " \
498 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
499 8d725ae1 2019-08-18 stsp printf "\tcodedocs/doxygen.conf\n" >> $testroot/stdout.expected
500 8d725ae1 2019-08-18 stsp echo -n "09) $short_commit1 $d1 $GOT_AUTHOR_8 " \
501 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
502 8d725ae1 2019-08-18 stsp printf "\tcontrib/powerdns.solaris.init.d\n" \
503 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
504 8d725ae1 2019-08-18 stsp echo -n "10) $short_commit1 $d1 $GOT_AUTHOR_8 " \
505 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
506 8d725ae1 2019-08-18 stsp printf "\tpdns/named.conf.parsertest\n" >> $testroot/stdout.expected
507 8d725ae1 2019-08-18 stsp echo -n "11) $short_commit1 $d1 $GOT_AUTHOR_8 " \
508 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
509 8d725ae1 2019-08-18 stsp printf "\tregression-tests/zones/unit.test\n" \
510 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
511 8d725ae1 2019-08-18 stsp echo -n "12) $short_commit4 $d4 $GOT_AUTHOR_8 " \
512 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
513 8d725ae1 2019-08-18 stsp printf "\tbuilder-support/gen-version\n" >> $testroot/stdout.expected
514 8d725ae1 2019-08-18 stsp echo "13) $short_commit1 $d1 $GOT_AUTHOR_8 " \
515 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
516 8d725ae1 2019-08-18 stsp echo -n "14) $short_commit1 $d1 $GOT_AUTHOR_8 " \
517 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
518 8d725ae1 2019-08-18 stsp echo "ACLOCAL_AMFLAGS = -I m4" \
519 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
520 8d725ae1 2019-08-18 stsp echo "15) $short_commit1 $d1 $GOT_AUTHOR_8 " \
521 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
522 8d725ae1 2019-08-18 stsp echo -n "16) $short_commit1 $d1 $GOT_AUTHOR_8 " \
523 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
524 8d725ae1 2019-08-18 stsp echo "dvi: # do nothing to build dvi" \
525 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
527 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
529 8d725ae1 2019-08-18 stsp if [ "$ret" != "0" ]; then
530 548237bc 2019-08-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
531 548237bc 2019-08-19 stsp test_done "$testroot" "$ret"
535 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
537 16357e96 2019-08-19 stsp test_done "$testroot" "$ret"
540 16357e96 2019-08-19 stsp function test_blame_blame_h {
541 16357e96 2019-08-19 stsp local testroot=`test_init blame_blame_h`
543 16357e96 2019-08-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
545 16357e96 2019-08-19 stsp if [ "$ret" != "0" ]; then
546 16357e96 2019-08-19 stsp test_done "$testroot" "$ret"
550 16357e96 2019-08-19 stsp cat > $testroot/wt/got_blame.h <<EOF
552 16357e96 2019-08-19 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
554 16357e96 2019-08-19 stsp * Permission to use, copy, modify, and distribute this software for any
555 16357e96 2019-08-19 stsp * purpose with or without fee is hereby granted, provided that the above
556 16357e96 2019-08-19 stsp * copyright notice and this permission notice appear in all copies.
558 16357e96 2019-08-19 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
559 16357e96 2019-08-19 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
560 16357e96 2019-08-19 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
561 16357e96 2019-08-19 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
562 16357e96 2019-08-19 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
563 16357e96 2019-08-19 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
564 16357e96 2019-08-19 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
567 16357e96 2019-08-19 stsp const struct got_error *got_blame(const char *, struct got_object_id *,
568 16357e96 2019-08-19 stsp struct got_repository *, FILE *);
570 16357e96 2019-08-19 stsp (cd $testroot/wt && got add got_blame.h > /dev/null)
571 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
573 16357e96 2019-08-19 stsp cat > $testroot/wt/blame-2.patch <<EOF
574 16357e96 2019-08-19 stsp diff 63581804340e880bf611c6a4a59eda26c503799f 84451b3ef755f3226d0d79af367632e5f3a830e7
575 16357e96 2019-08-19 stsp blob - b53ca469a18871cc2f6af334dab25028599c6488
576 16357e96 2019-08-19 stsp blob + c787aadf05e2afab61bd34976f7349912252e6da
577 16357e96 2019-08-19 stsp --- got_blame.h
578 16357e96 2019-08-19 stsp +++ got_blame.h
579 16357e96 2019-08-19 stsp @@ -14,5 +14,22 @@
580 16357e96 2019-08-19 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
584 16357e96 2019-08-19 stsp + * Write an annotated version of a file at a given in-repository path,
585 16357e96 2019-08-19 stsp + * as found in the commit specified by ID, to the specified output file.
587 16357e96 2019-08-19 stsp const struct got_error *got_blame(const char *, struct got_object_id *,
588 16357e96 2019-08-19 stsp struct got_repository *, FILE *);
591 16357e96 2019-08-19 stsp + * Like got_blame() but instead of generating an output file invoke
592 16357e96 2019-08-19 stsp + * a callback whenever an annotation has been computed for a line.
594 16357e96 2019-08-19 stsp + * The callback receives the provided void * argument, the total number
595 16357e96 2019-08-19 stsp + * of lines of the annotated file, a line number, and the ID of the commit
596 16357e96 2019-08-19 stsp + * which last changed this line.
598 16357e96 2019-08-19 stsp +const struct got_error *got_blame_incremental(const char *,
599 16357e96 2019-08-19 stsp + struct got_object_id *, struct got_repository *,
600 16357e96 2019-08-19 stsp + const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
603 16357e96 2019-08-19 stsp (cd $testroot/wt && patch < blame-2.patch > /dev/null)
604 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
606 16357e96 2019-08-19 stsp cat > $testroot/wt/blame-3.patch <<EOF
607 16357e96 2019-08-19 stsp diff 75b7a700d9d14ef8eb902961255212acbedef164 d68a0a7de13af722c55099582019c03240e13320
608 16357e96 2019-08-19 stsp blob - c787aadf05e2afab61bd34976f7349912252e6da
609 16357e96 2019-08-19 stsp blob + 5255d076c915accf159940978b821d06803ff2f8
610 16357e96 2019-08-19 stsp --- got_blame.h
611 16357e96 2019-08-19 stsp +++ got_blame.h
612 16357e96 2019-08-19 stsp @@ -28,6 +28,15 @@ const struct got_error *got_blame(const char *, struct
613 16357e96 2019-08-19 stsp * The callback receives the provided void * argument, the total number
614 16357e96 2019-08-19 stsp * of lines of the annotated file, a line number, and the ID of the commit
615 16357e96 2019-08-19 stsp * which last changed this line.
617 16357e96 2019-08-19 stsp + * The callback is invoked for each commit as history is traversed.
618 16357e96 2019-08-19 stsp + * If no changes to the file were made in a commit, line number -1 and
619 16357e96 2019-08-19 stsp + * commit ID NULL will be reported.
621 16357e96 2019-08-19 stsp + * If the callback returns GOT_ERR_ITER_COMPLETED, the blame operation
622 16357e96 2019-08-19 stsp + * will be aborted and this function returns NULL.
623 16357e96 2019-08-19 stsp + * If the callback returns any other error, the blame operation will be
624 16357e96 2019-08-19 stsp + * aborted and the callback's error is returned from this function.
626 16357e96 2019-08-19 stsp const struct got_error *got_blame_incremental(const char *,
627 16357e96 2019-08-19 stsp struct got_object_id *, struct got_repository *,
629 16357e96 2019-08-19 stsp (cd $testroot/wt && patch < blame-3.patch > /dev/null)
630 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
632 16357e96 2019-08-19 stsp cat > $testroot/wt/blame-4.patch <<EOF
633 16357e96 2019-08-19 stsp diff 3f60a8ef49086101685260fcb829f578cdf6d320 3bf198ba335fa30c8d16efb5c8e496200ac99c05
634 16357e96 2019-08-19 stsp blob - 5255d076c915accf159940978b821d06803ff2f8
635 16357e96 2019-08-19 stsp blob + 39623c468e733ee08abb50eafe29202b2b0a04ef
636 16357e96 2019-08-19 stsp --- got_blame.h
637 16357e96 2019-08-19 stsp +++ got_blame.h
638 16357e96 2019-08-19 stsp @@ -30,8 +30,8 @@ const struct got_error *got_blame(const char *, struct
639 16357e96 2019-08-19 stsp * which last changed this line.
641 16357e96 2019-08-19 stsp * The callback is invoked for each commit as history is traversed.
642 16357e96 2019-08-19 stsp - * If no changes to the file were made in a commit, line number -1 and
643 16357e96 2019-08-19 stsp - * commit ID NULL will be reported.
644 16357e96 2019-08-19 stsp + * If no changes to the file were made in a commit, line number -1 will
645 16357e96 2019-08-19 stsp + * be reported.
647 16357e96 2019-08-19 stsp * If the callback returns GOT_ERR_ITER_COMPLETED, the blame operation
648 16357e96 2019-08-19 stsp * will be aborted and this function returns NULL.
650 16357e96 2019-08-19 stsp (cd $testroot/wt && patch < blame-4.patch > /dev/null)
651 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 4" > /dev/null)
653 16357e96 2019-08-19 stsp cat > $testroot/wt/blame-5.patch <<EOF
654 16357e96 2019-08-19 stsp diff 28315671b93d195163b0468fcb3879e29b25759c e27a7222faaa171dcb086ea0b566dc7bebb74a0b
655 16357e96 2019-08-19 stsp blob - 39623c468e733ee08abb50eafe29202b2b0a04ef
656 16357e96 2019-08-19 stsp blob + 6075cadbd177e1802679c7353515bf4ceebb51d0
657 16357e96 2019-08-19 stsp --- got_blame.h
658 16357e96 2019-08-19 stsp +++ got_blame.h
659 16357e96 2019-08-19 stsp @@ -15,14 +15,7 @@
663 16357e96 2019-08-19 stsp - * Write an annotated version of a file at a given in-repository path,
664 16357e96 2019-08-19 stsp - * as found in the commit specified by ID, to the specified output file.
666 16357e96 2019-08-19 stsp -const struct got_error *got_blame(const char *, struct got_object_id *,
667 16357e96 2019-08-19 stsp - struct got_repository *, FILE *);
670 16357e96 2019-08-19 stsp - * Like got_blame() but instead of generating an output file invoke
671 16357e96 2019-08-19 stsp + * Blame the blob at the specified path in the specified commit and invoke
672 16357e96 2019-08-19 stsp * a callback whenever an annotation has been computed for a line.
674 16357e96 2019-08-19 stsp * The callback receives the provided void * argument, the total number
676 16357e96 2019-08-19 stsp (cd $testroot/wt && patch < blame-5.patch > /dev/null)
677 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 5" > /dev/null)
679 4c9641fd 2019-08-21 stsp blame_cmp "$testroot" "got_blame.h"
681 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
684 c970ea82 2019-07-27 stsp run_test test_blame_basic
685 303e2782 2019-08-09 stsp run_test test_blame_tag
686 78695fb7 2019-08-12 stsp run_test test_blame_file_single_line
687 78695fb7 2019-08-12 stsp run_test test_blame_file_single_line_no_newline
688 8d725ae1 2019-08-18 stsp run_test test_blame_all_lines_replaced
689 8d725ae1 2019-08-18 stsp run_test test_blame_lines_shifted_up
690 8d725ae1 2019-08-18 stsp run_test test_blame_lines_shifted_down
691 8d725ae1 2019-08-18 stsp run_test test_blame_commit_subsumed
692 16357e96 2019-08-19 stsp run_test test_blame_blame_h