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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 dc8256b6 2021-08-31 naddy d=`date -u -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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 dc8256b6 2021-08-31 naddy d=`date -u -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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 dc8256b6 2021-08-31 naddy d=`date -u -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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 dc8256b6 2021-08-31 naddy d=`date -u -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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 dc8256b6 2021-08-31 naddy d=`date -u -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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 dc8256b6 2021-08-31 naddy d=`date -u -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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 dc8256b6 2021-08-31 naddy d=`date -u -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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 dc8256b6 2021-08-31 naddy local d1=`date -u -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 dc8256b6 2021-08-31 naddy local d2=`date -u -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 dc8256b6 2021-08-31 naddy local d3=`date -u -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 dc8256b6 2021-08-31 naddy local d4=`date -u -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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
540 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 16357e96 2019-08-19 stsp test_done "$testroot" "$ret"
684 f6cae3ed 2020-09-13 naddy test_blame_added_on_branch() {
685 db32465d 2020-02-07 stsp local testroot=`test_init blame_added_on_branch`
687 db32465d 2020-02-07 stsp got branch -r $testroot/repo -c master newbranch
689 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
690 db32465d 2020-02-07 stsp test_done "$testroot" "$ret"
694 db32465d 2020-02-07 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
696 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
697 db32465d 2020-02-07 stsp test_done "$testroot" "$ret"
701 db32465d 2020-02-07 stsp echo 1 > $testroot/wt/new
702 db32465d 2020-02-07 stsp (cd $testroot/wt && got add new > /dev/null)
703 db32465d 2020-02-07 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
704 db32465d 2020-02-07 stsp local commit1=`git_show_branch_head $testroot/repo newbranch`
706 db32465d 2020-02-07 stsp echo 2 >> $testroot/wt/new
707 db32465d 2020-02-07 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
708 db32465d 2020-02-07 stsp local commit2=`git_show_branch_head $testroot/repo newbranch`
710 db32465d 2020-02-07 stsp echo 3 >> $testroot/wt/new
711 db32465d 2020-02-07 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
712 db32465d 2020-02-07 stsp local commit3=`git_show_branch_head $testroot/repo newbranch`
713 db32465d 2020-02-07 stsp local author_time=`git_show_author_time $testroot/repo`
715 db32465d 2020-02-07 stsp (cd $testroot/wt && got blame new > $testroot/stdout)
717 db32465d 2020-02-07 stsp local short_commit1=`trim_obj_id 32 $commit1`
718 db32465d 2020-02-07 stsp local short_commit2=`trim_obj_id 32 $commit2`
719 db32465d 2020-02-07 stsp local short_commit3=`trim_obj_id 32 $commit3`
721 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
722 db32465d 2020-02-07 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
723 db32465d 2020-02-07 stsp echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
724 db32465d 2020-02-07 stsp echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
726 db32465d 2020-02-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
728 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
729 db32465d 2020-02-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
731 db32465d 2020-02-07 stsp test_done "$testroot" "$ret"
734 f6cae3ed 2020-09-13 naddy test_blame_submodule() {
735 e7303626 2020-05-14 stsp local testroot=`test_init blame_submodule`
736 e7303626 2020-05-14 stsp local commit_id0=`git_show_head $testroot/repo`
737 e7303626 2020-05-14 stsp local author_time=`git_show_author_time $testroot/repo`
739 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
741 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
742 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
743 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
745 e7303626 2020-05-14 stsp # Attempt a (nonsensical) blame of a submodule.
746 e7303626 2020-05-14 stsp got blame -r $testroot/repo repo2 \
747 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
749 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
750 e7303626 2020-05-14 stsp echo "blame command succeeded unexpectedly" >&2
751 e7303626 2020-05-14 stsp test_done "$testroot" "1"
754 e7303626 2020-05-14 stsp local submodule_id=$(got tree -r $testroot/repo -i | \
755 e7303626 2020-05-14 stsp grep 'repo2\$$' | cut -d ' ' -f1)
756 e7303626 2020-05-14 stsp echo "got: object $submodule_id not found" > $testroot/stderr.expected
758 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
760 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
761 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
763 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
766 f6cae3ed 2020-09-13 naddy test_blame_symlink() {
767 0587e10c 2020-07-23 stsp local testroot=`test_init blame_symlink`
768 0587e10c 2020-07-23 stsp local commit_id0=`git_show_head $testroot/repo`
769 0587e10c 2020-07-23 stsp local short_commit0=`trim_obj_id 32 $commit_id0`
771 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
772 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
773 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
774 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
775 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
776 0587e10c 2020-07-23 stsp (cd $testroot/repo && git add .)
777 0587e10c 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
779 0587e10c 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
780 0587e10c 2020-07-23 stsp local short_commit1=`trim_obj_id 32 $commit_id1`
781 0587e10c 2020-07-23 stsp local author_time=`git_show_author_time $testroot/repo`
783 0587e10c 2020-07-23 stsp # got blame dereferences symlink to a regular file
784 0587e10c 2020-07-23 stsp got blame -r $testroot/repo alpha.link > $testroot/stdout
786 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
787 0587e10c 2020-07-23 stsp echo "blame command failed unexpectedly" >&2
788 0587e10c 2020-07-23 stsp test_done "$testroot" "$ret"
792 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
793 0587e10c 2020-07-23 stsp echo "1) $short_commit0 $d $GOT_AUTHOR_8 alpha" \
794 0587e10c 2020-07-23 stsp > $testroot/stdout.expected
796 0587e10c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
798 49c543a6 2022-03-31 naddy if [ $ret -ne 0 -a "$xfail" = "" ]; then
799 0587e10c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
800 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
804 0587e10c 2020-07-23 stsp # got blame dereferences symlink with relative path
805 0587e10c 2020-07-23 stsp got blame -r $testroot/repo epsilon/beta.link > $testroot/stdout
807 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
808 0587e10c 2020-07-23 stsp echo "blame command failed unexpectedly" >&2
809 0587e10c 2020-07-23 stsp test_done "$testroot" "$ret"
813 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
814 0587e10c 2020-07-23 stsp echo "1) $short_commit0 $d $GOT_AUTHOR_8 beta" \
815 0587e10c 2020-07-23 stsp > $testroot/stdout.expected
817 0587e10c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
819 49c543a6 2022-03-31 naddy if [ $ret -ne 0 -a "$xfail" = "" ]; then
820 0587e10c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
821 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
825 0587e10c 2020-07-23 stsp got blame -r $testroot/repo epsilon.link > $testroot/stdout \
826 0587e10c 2020-07-23 stsp 2> $testroot/stderr
828 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
829 0587e10c 2020-07-23 stsp echo "blame command succeeded unexpectedly" >&2
830 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
834 0587e10c 2020-07-23 stsp # blame dereferences symlink to a directory
835 eb59b6d4 2020-07-23 stsp echo "got: /epsilon: wrong type of object" > $testroot/stderr.expected
836 0587e10c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
838 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
839 0587e10c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
840 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
844 0587e10c 2020-07-23 stsp # got blame fails if symlink target does not exist in repo
845 0587e10c 2020-07-23 stsp got blame -r $testroot/repo passwd.link > $testroot/stdout \
846 0587e10c 2020-07-23 stsp 2> $testroot/stderr
848 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
849 0587e10c 2020-07-23 stsp echo "blame command succeeded unexpectedly" >&2
850 a19f439c 2022-06-03 op test_done "$testroot" "1"
854 0587e10c 2020-07-23 stsp echo "got: /etc/passwd: no such entry found in tree" \
855 0587e10c 2020-07-23 stsp > $testroot/stderr.expected
856 0587e10c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
858 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
859 0587e10c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
860 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
864 0587e10c 2020-07-23 stsp got blame -r $testroot/repo nonexistent.link > $testroot/stdout \
865 0587e10c 2020-07-23 stsp 2> $testroot/stderr
867 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
868 0587e10c 2020-07-23 stsp echo "blame command succeeded unexpectedly" >&2
869 a19f439c 2022-06-03 op test_done "$testroot" "1"
873 0587e10c 2020-07-23 stsp echo "got: /nonexistent: no such entry found in tree" \
874 0587e10c 2020-07-23 stsp > $testroot/stderr.expected
875 0587e10c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
877 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
878 0587e10c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
879 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
883 0587e10c 2020-07-23 stsp test_done "$testroot" "$ret"
886 c27a5e66 2020-11-18 stsp test_blame_lines_shifted_skip() {
887 c27a5e66 2020-11-18 stsp local testroot=`test_init blame_lines_shifted_skip`
889 c27a5e66 2020-11-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
891 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
892 c27a5e66 2020-11-18 stsp test_done "$testroot" "$ret"
896 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
902 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
903 c27a5e66 2020-11-18 stsp local commit1=`git_show_head $testroot/repo`
904 c27a5e66 2020-11-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
905 c27a5e66 2020-11-18 stsp local author_time=`git_show_author_time $testroot/repo`
907 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
915 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
916 c27a5e66 2020-11-18 stsp local commit2=`git_show_head $testroot/repo`
917 c27a5e66 2020-11-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
919 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
928 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
929 c27a5e66 2020-11-18 stsp local commit3=`git_show_head $testroot/repo`
930 c27a5e66 2020-11-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
931 c27a5e66 2020-11-18 stsp local author_time=`git_show_author_time $testroot/repo`
933 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
941 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 4" > /dev/null)
942 c27a5e66 2020-11-18 stsp local commit4=`git_show_head $testroot/repo`
943 c27a5e66 2020-11-18 stsp local short_commit4=`trim_obj_id 32 $commit4`
944 c27a5e66 2020-11-18 stsp local author_time=`git_show_author_time $testroot/repo`
946 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
955 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 5" > /dev/null)
956 c27a5e66 2020-11-18 stsp local commit5=`git_show_head $testroot/repo`
957 c27a5e66 2020-11-18 stsp local short_commit5=`trim_obj_id 32 $commit5`
958 c27a5e66 2020-11-18 stsp local author_time=`git_show_author_time $testroot/repo`
960 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
962 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
963 c27a5e66 2020-11-18 stsp echo "1) $short_commit5 $d $GOT_AUTHOR_8 X" > $testroot/stdout.expected
964 c27a5e66 2020-11-18 stsp echo "2) $short_commit1 $d $GOT_AUTHOR_8 A" >> $testroot/stdout.expected
965 c27a5e66 2020-11-18 stsp echo "3) $short_commit1 $d $GOT_AUTHOR_8 B" >> $testroot/stdout.expected
966 c27a5e66 2020-11-18 stsp echo "4) $short_commit1 $d $GOT_AUTHOR_8 C" >> $testroot/stdout.expected
967 c27a5e66 2020-11-18 stsp echo "5) $short_commit2 $d $GOT_AUTHOR_8 P" >> $testroot/stdout.expected
968 c27a5e66 2020-11-18 stsp echo "6) $short_commit4 $d $GOT_AUTHOR_8 Y" >> $testroot/stdout.expected
969 c27a5e66 2020-11-18 stsp echo "7) $short_commit2 $d $GOT_AUTHOR_8 Q" >> $testroot/stdout.expected
971 c27a5e66 2020-11-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
973 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
974 c27a5e66 2020-11-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
975 c27a5e66 2020-11-18 stsp test_done "$testroot" "$ret"
979 c27a5e66 2020-11-18 stsp blame_cmp "$testroot" "alpha"
981 c27a5e66 2020-11-18 stsp test_done "$testroot" "$ret"
984 7fb414ae 2020-08-08 stsp test_parseargs "$@"
985 c970ea82 2019-07-27 stsp run_test test_blame_basic
986 303e2782 2019-08-09 stsp run_test test_blame_tag
987 78695fb7 2019-08-12 stsp run_test test_blame_file_single_line
988 78695fb7 2019-08-12 stsp run_test test_blame_file_single_line_no_newline
989 8d725ae1 2019-08-18 stsp run_test test_blame_all_lines_replaced
990 8d725ae1 2019-08-18 stsp run_test test_blame_lines_shifted_up
991 8d725ae1 2019-08-18 stsp run_test test_blame_lines_shifted_down
992 8d725ae1 2019-08-18 stsp run_test test_blame_commit_subsumed
993 16357e96 2019-08-19 stsp run_test test_blame_blame_h
994 db32465d 2020-02-07 stsp run_test test_blame_added_on_branch
995 e7303626 2020-05-14 stsp run_test test_blame_submodule
996 0587e10c 2020-07-23 stsp run_test test_blame_symlink
997 c27a5e66 2020-11-18 stsp run_test test_blame_lines_shifted_skip