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 f73bf5bd 2023-10-01 naddy git -C $testroot/repo reset --hard master > /dev/null
27 f73bf5bd 2023-10-01 naddy git -C $testroot/repo blame "$file" | cut -d ' ' -f 1 \
28 f73bf5bd 2023-10-01 naddy > $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 f73bf5bd 2023-10-01 naddy git -C $testroot/repo 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 2fed5287 2024-04-09 op seq 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 2fed5287 2024-04-09 op seq 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 885e96df 2023-03-06 naddy ed -s $testroot/wt/alpha <<-\EOF
252 885e96df 2023-03-06 naddy g/^[345]$/d
255 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
256 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
257 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
259 2fed5287 2024-04-09 op seq 2 > $testroot/wt/alpha
260 8d725ae1 2019-08-18 stsp echo foo >> $testroot/wt/alpha
261 8d725ae1 2019-08-18 stsp echo bar >> $testroot/wt/alpha
262 8d725ae1 2019-08-18 stsp echo baz >> $testroot/wt/alpha
263 2fed5287 2024-04-09 op seq 6 8 >> $testroot/wt/alpha
264 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
265 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
266 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
267 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
269 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
271 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
272 8d725ae1 2019-08-18 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
273 8d725ae1 2019-08-18 stsp echo "2) $short_commit1 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
274 8d725ae1 2019-08-18 stsp echo "3) $short_commit3 $d $GOT_AUTHOR_8 foo" >> $testroot/stdout.expected
275 8d725ae1 2019-08-18 stsp echo "4) $short_commit3 $d $GOT_AUTHOR_8 bar" >> $testroot/stdout.expected
276 8d725ae1 2019-08-18 stsp echo "5) $short_commit3 $d $GOT_AUTHOR_8 baz" >> $testroot/stdout.expected
277 8d725ae1 2019-08-18 stsp echo "6) $short_commit1 $d $GOT_AUTHOR_8 6" >> $testroot/stdout.expected
278 8d725ae1 2019-08-18 stsp echo "7) $short_commit1 $d $GOT_AUTHOR_8 7" >> $testroot/stdout.expected
279 8d725ae1 2019-08-18 stsp echo "8) $short_commit1 $d $GOT_AUTHOR_8 8" >> $testroot/stdout.expected
281 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
283 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
284 8d725ae1 2019-08-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
285 b24db1c1 2019-08-19 stsp test_done "$testroot" "$ret"
289 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
291 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
294 f6cae3ed 2020-09-13 naddy test_blame_lines_shifted_down() {
295 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_lines_shifted_down`
297 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
299 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
300 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
304 2fed5287 2024-04-09 op seq 8 > $testroot/wt/alpha
305 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
306 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
307 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
308 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
310 885e96df 2023-03-06 naddy ed -s $testroot/wt/alpha <<-\EOF
314 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
315 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
316 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
318 2fed5287 2024-04-09 op seq 2 > $testroot/wt/alpha
319 8d725ae1 2019-08-18 stsp echo foo >> $testroot/wt/alpha
320 8d725ae1 2019-08-18 stsp echo bar >> $testroot/wt/alpha
321 8d725ae1 2019-08-18 stsp echo baz >> $testroot/wt/alpha
322 2fed5287 2024-04-09 op seq 3 8 >> $testroot/wt/alpha
323 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
324 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
325 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
326 8d725ae1 2019-08-18 stsp local author_time=`git_show_author_time $testroot/repo`
328 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
330 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
331 8d725ae1 2019-08-18 stsp echo "01) $short_commit1 $d $GOT_AUTHOR_8 1" \
332 8d725ae1 2019-08-18 stsp > $testroot/stdout.expected
333 8d725ae1 2019-08-18 stsp echo "02) $short_commit1 $d $GOT_AUTHOR_8 2" \
334 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
335 8d725ae1 2019-08-18 stsp echo "03) $short_commit3 $d $GOT_AUTHOR_8 foo" \
336 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
337 8d725ae1 2019-08-18 stsp echo "04) $short_commit3 $d $GOT_AUTHOR_8 bar" \
338 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
339 8d725ae1 2019-08-18 stsp echo "05) $short_commit3 $d $GOT_AUTHOR_8 baz" \
340 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
341 8d725ae1 2019-08-18 stsp echo "06) $short_commit1 $d $GOT_AUTHOR_8 3" \
342 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
343 8d725ae1 2019-08-18 stsp echo "07) $short_commit1 $d $GOT_AUTHOR_8 4" \
344 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
345 8d725ae1 2019-08-18 stsp echo "08) $short_commit1 $d $GOT_AUTHOR_8 5" \
346 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
347 8d725ae1 2019-08-18 stsp echo "09) $short_commit1 $d $GOT_AUTHOR_8 6" \
348 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
349 8d725ae1 2019-08-18 stsp echo "10) $short_commit1 $d $GOT_AUTHOR_8 7" \
350 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
351 8d725ae1 2019-08-18 stsp echo "11) $short_commit3 $d $GOT_AUTHOR_8 8" \
352 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
354 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
356 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
357 8d725ae1 2019-08-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
358 b24db1c1 2019-08-19 stsp test_done "$testroot" "$ret"
362 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
364 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
367 f6cae3ed 2020-09-13 naddy test_blame_commit_subsumed() {
368 8d725ae1 2019-08-18 stsp local testroot=`test_init blame_commit_subsumed`
370 8d725ae1 2019-08-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
372 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
373 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
377 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
378 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules codedocs docs
380 8d725ae1 2019-08-18 stsp if WITH_PDNS_SERVER
381 8d725ae1 2019-08-18 stsp SUBDIRS += pdns
384 8d725ae1 2019-08-18 stsp EXTRA_DIST =
389 8d725ae1 2019-08-18 stsp build-aux/gen-version
390 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
391 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
392 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
393 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
395 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
397 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
399 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
400 8d725ae1 2019-08-18 stsp local commit1=`git_show_head $testroot/repo`
401 8d725ae1 2019-08-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
402 8d725ae1 2019-08-18 stsp local author_time1=`git_show_author_time $testroot/repo`
403 dc8256b6 2021-08-31 naddy local d1=`date -u -r $author_time1 +"%G-%m-%d"`
405 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
406 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules codedocs docs
408 8d725ae1 2019-08-18 stsp SUBDIRS += pdns
410 8d725ae1 2019-08-18 stsp EXTRA_DIST =
415 8d725ae1 2019-08-18 stsp build-aux/gen-version
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
421 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
423 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
425 8d725ae1 2019-08-18 stsp # all changes in this commit will be subsumed by later commits
426 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
427 8d725ae1 2019-08-18 stsp local commit2=`git_show_head $testroot/repo`
428 8d725ae1 2019-08-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
429 8d725ae1 2019-08-18 stsp local author_time2=`git_show_author_time $testroot/repo`
430 dc8256b6 2021-08-31 naddy local d2=`date -u -r $author_time2 +"%G-%m-%d"`
432 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
433 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules pdns codedocs docs
435 8d725ae1 2019-08-18 stsp EXTRA_DIST =
440 8d725ae1 2019-08-18 stsp build-aux/gen-version
441 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
442 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
443 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
444 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
446 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
448 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
450 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
451 8d725ae1 2019-08-18 stsp local commit3=`git_show_head $testroot/repo`
452 8d725ae1 2019-08-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
453 8d725ae1 2019-08-18 stsp local author_time3=`git_show_author_time $testroot/repo`
454 dc8256b6 2021-08-31 naddy local d3=`date -u -r $author_time3 +"%G-%m-%d"`
456 8d725ae1 2019-08-18 stsp cat > $testroot/wt/alpha <<EOF
457 8d725ae1 2019-08-18 stsp SUBDIRS = ext modules pdns codedocs docs
459 8d725ae1 2019-08-18 stsp EXTRA_DIST =
464 8d725ae1 2019-08-18 stsp codedocs/doxygen.conf
465 8d725ae1 2019-08-18 stsp contrib/powerdns.solaris.init.d
466 8d725ae1 2019-08-18 stsp pdns/named.conf.parsertest
467 8d725ae1 2019-08-18 stsp regression-tests/zones/unit.test
468 8d725ae1 2019-08-18 stsp builder-support/gen-version
470 8d725ae1 2019-08-18 stsp ACLOCAL_AMFLAGS = -I m4
472 8d725ae1 2019-08-18 stsp dvi: # do nothing to build dvi
474 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got commit -m "change 4" > /dev/null)
475 8d725ae1 2019-08-18 stsp local commit4=`git_show_head $testroot/repo`
476 8d725ae1 2019-08-18 stsp local short_commit4=`trim_obj_id 32 $commit4`
477 8d725ae1 2019-08-18 stsp local author_time4=`git_show_author_time $testroot/repo`
478 dc8256b6 2021-08-31 naddy local d4=`date -u -r $author_time4 +"%G-%m-%d"`
480 8d725ae1 2019-08-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
482 8d725ae1 2019-08-18 stsp echo -n "01) $short_commit3 $d3 $GOT_AUTHOR_8 " \
483 8d725ae1 2019-08-18 stsp > $testroot/stdout.expected
484 8d725ae1 2019-08-18 stsp echo "SUBDIRS = ext modules pdns codedocs docs" \
485 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
486 8d725ae1 2019-08-18 stsp echo "02) $short_commit1 $d1 $GOT_AUTHOR_8 " \
487 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
488 8d725ae1 2019-08-18 stsp echo -n "03) $short_commit1 $d1 $GOT_AUTHOR_8 " \
489 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
490 8d725ae1 2019-08-18 stsp echo 'EXTRA_DIST =' >> $testroot/stdout.expected
491 8d725ae1 2019-08-18 stsp echo -n "04) $short_commit1 $d1 $GOT_AUTHOR_8 " \
492 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
493 8d725ae1 2019-08-18 stsp printf "\tINSTALL\n" >> $testroot/stdout.expected
494 8d725ae1 2019-08-18 stsp echo -n "05) $short_commit1 $d1 $GOT_AUTHOR_8 " \
495 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
496 8d725ae1 2019-08-18 stsp printf "\tNOTICE\n" >> $testroot/stdout.expected
497 8d725ae1 2019-08-18 stsp echo -n "06) $short_commit1 $d1 $GOT_AUTHOR_8 " \
498 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
499 8d725ae1 2019-08-18 stsp printf "\tREADME\n" >> $testroot/stdout.expected
500 8d725ae1 2019-08-18 stsp echo -n "07) $short_commit4 $d4 $GOT_AUTHOR_8 " \
501 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
502 8d725ae1 2019-08-18 stsp printf "\tCOPYING\n" >> $testroot/stdout.expected
503 8d725ae1 2019-08-18 stsp echo -n "08) $short_commit1 $d1 $GOT_AUTHOR_8 " \
504 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
505 8d725ae1 2019-08-18 stsp printf "\tcodedocs/doxygen.conf\n" >> $testroot/stdout.expected
506 8d725ae1 2019-08-18 stsp echo -n "09) $short_commit1 $d1 $GOT_AUTHOR_8 " \
507 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
508 8d725ae1 2019-08-18 stsp printf "\tcontrib/powerdns.solaris.init.d\n" \
509 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
510 8d725ae1 2019-08-18 stsp echo -n "10) $short_commit1 $d1 $GOT_AUTHOR_8 " \
511 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
512 8d725ae1 2019-08-18 stsp printf "\tpdns/named.conf.parsertest\n" >> $testroot/stdout.expected
513 8d725ae1 2019-08-18 stsp echo -n "11) $short_commit1 $d1 $GOT_AUTHOR_8 " \
514 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
515 8d725ae1 2019-08-18 stsp printf "\tregression-tests/zones/unit.test\n" \
516 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
517 8d725ae1 2019-08-18 stsp echo -n "12) $short_commit4 $d4 $GOT_AUTHOR_8 " \
518 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
519 8d725ae1 2019-08-18 stsp printf "\tbuilder-support/gen-version\n" >> $testroot/stdout.expected
520 8d725ae1 2019-08-18 stsp echo "13) $short_commit1 $d1 $GOT_AUTHOR_8 " \
521 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
522 8d725ae1 2019-08-18 stsp echo -n "14) $short_commit1 $d1 $GOT_AUTHOR_8 " \
523 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
524 8d725ae1 2019-08-18 stsp echo "ACLOCAL_AMFLAGS = -I m4" \
525 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
526 8d725ae1 2019-08-18 stsp echo "15) $short_commit1 $d1 $GOT_AUTHOR_8 " \
527 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
528 8d725ae1 2019-08-18 stsp echo -n "16) $short_commit1 $d1 $GOT_AUTHOR_8 " \
529 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
530 8d725ae1 2019-08-18 stsp echo "dvi: # do nothing to build dvi" \
531 8d725ae1 2019-08-18 stsp >> $testroot/stdout.expected
533 8d725ae1 2019-08-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
535 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
536 548237bc 2019-08-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
537 548237bc 2019-08-19 stsp test_done "$testroot" "$ret"
541 b24db1c1 2019-08-19 stsp blame_cmp "$testroot" "alpha"
543 16357e96 2019-08-19 stsp test_done "$testroot" "$ret"
546 f6cae3ed 2020-09-13 naddy test_blame_blame_h() {
547 16357e96 2019-08-19 stsp local testroot=`test_init blame_blame_h`
549 16357e96 2019-08-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
551 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
552 16357e96 2019-08-19 stsp test_done "$testroot" "$ret"
556 16357e96 2019-08-19 stsp cat > $testroot/wt/got_blame.h <<EOF
558 16357e96 2019-08-19 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
560 16357e96 2019-08-19 stsp * Permission to use, copy, modify, and distribute this software for any
561 16357e96 2019-08-19 stsp * purpose with or without fee is hereby granted, provided that the above
562 16357e96 2019-08-19 stsp * copyright notice and this permission notice appear in all copies.
564 16357e96 2019-08-19 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
565 16357e96 2019-08-19 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
566 16357e96 2019-08-19 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
567 16357e96 2019-08-19 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
568 16357e96 2019-08-19 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
569 16357e96 2019-08-19 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
570 16357e96 2019-08-19 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
573 16357e96 2019-08-19 stsp const struct got_error *got_blame(const char *, struct got_object_id *,
574 16357e96 2019-08-19 stsp struct got_repository *, FILE *);
576 16357e96 2019-08-19 stsp (cd $testroot/wt && got add got_blame.h > /dev/null)
577 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
579 16357e96 2019-08-19 stsp cat > $testroot/wt/blame-2.patch <<EOF
580 16357e96 2019-08-19 stsp diff 63581804340e880bf611c6a4a59eda26c503799f 84451b3ef755f3226d0d79af367632e5f3a830e7
581 16357e96 2019-08-19 stsp blob - b53ca469a18871cc2f6af334dab25028599c6488
582 16357e96 2019-08-19 stsp blob + c787aadf05e2afab61bd34976f7349912252e6da
583 16357e96 2019-08-19 stsp --- got_blame.h
584 16357e96 2019-08-19 stsp +++ got_blame.h
585 16357e96 2019-08-19 stsp @@ -14,5 +14,22 @@
586 16357e96 2019-08-19 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
590 16357e96 2019-08-19 stsp + * Write an annotated version of a file at a given in-repository path,
591 16357e96 2019-08-19 stsp + * as found in the commit specified by ID, to the specified output file.
593 16357e96 2019-08-19 stsp const struct got_error *got_blame(const char *, struct got_object_id *,
594 16357e96 2019-08-19 stsp struct got_repository *, FILE *);
597 16357e96 2019-08-19 stsp + * Like got_blame() but instead of generating an output file invoke
598 16357e96 2019-08-19 stsp + * a callback whenever an annotation has been computed for a line.
600 16357e96 2019-08-19 stsp + * The callback receives the provided void * argument, the total number
601 16357e96 2019-08-19 stsp + * of lines of the annotated file, a line number, and the ID of the commit
602 16357e96 2019-08-19 stsp + * which last changed this line.
604 16357e96 2019-08-19 stsp +const struct got_error *got_blame_incremental(const char *,
605 16357e96 2019-08-19 stsp + struct got_object_id *, struct got_repository *,
606 16357e96 2019-08-19 stsp + const struct got_error *(*cb)(void *, int, int, struct got_object_id *),
609 16357e96 2019-08-19 stsp (cd $testroot/wt && patch < blame-2.patch > /dev/null)
610 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
612 16357e96 2019-08-19 stsp cat > $testroot/wt/blame-3.patch <<EOF
613 16357e96 2019-08-19 stsp diff 75b7a700d9d14ef8eb902961255212acbedef164 d68a0a7de13af722c55099582019c03240e13320
614 16357e96 2019-08-19 stsp blob - c787aadf05e2afab61bd34976f7349912252e6da
615 16357e96 2019-08-19 stsp blob + 5255d076c915accf159940978b821d06803ff2f8
616 16357e96 2019-08-19 stsp --- got_blame.h
617 16357e96 2019-08-19 stsp +++ got_blame.h
618 16357e96 2019-08-19 stsp @@ -28,6 +28,15 @@ const struct got_error *got_blame(const char *, struct
619 16357e96 2019-08-19 stsp * The callback receives the provided void * argument, the total number
620 16357e96 2019-08-19 stsp * of lines of the annotated file, a line number, and the ID of the commit
621 16357e96 2019-08-19 stsp * which last changed this line.
623 16357e96 2019-08-19 stsp + * The callback is invoked for each commit as history is traversed.
624 16357e96 2019-08-19 stsp + * If no changes to the file were made in a commit, line number -1 and
625 16357e96 2019-08-19 stsp + * commit ID NULL will be reported.
627 16357e96 2019-08-19 stsp + * If the callback returns GOT_ERR_ITER_COMPLETED, the blame operation
628 16357e96 2019-08-19 stsp + * will be aborted and this function returns NULL.
629 16357e96 2019-08-19 stsp + * If the callback returns any other error, the blame operation will be
630 16357e96 2019-08-19 stsp + * aborted and the callback's error is returned from this function.
632 16357e96 2019-08-19 stsp const struct got_error *got_blame_incremental(const char *,
633 16357e96 2019-08-19 stsp struct got_object_id *, struct got_repository *,
635 16357e96 2019-08-19 stsp (cd $testroot/wt && patch < blame-3.patch > /dev/null)
636 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
638 16357e96 2019-08-19 stsp cat > $testroot/wt/blame-4.patch <<EOF
639 16357e96 2019-08-19 stsp diff 3f60a8ef49086101685260fcb829f578cdf6d320 3bf198ba335fa30c8d16efb5c8e496200ac99c05
640 16357e96 2019-08-19 stsp blob - 5255d076c915accf159940978b821d06803ff2f8
641 16357e96 2019-08-19 stsp blob + 39623c468e733ee08abb50eafe29202b2b0a04ef
642 16357e96 2019-08-19 stsp --- got_blame.h
643 16357e96 2019-08-19 stsp +++ got_blame.h
644 16357e96 2019-08-19 stsp @@ -30,8 +30,8 @@ const struct got_error *got_blame(const char *, struct
645 16357e96 2019-08-19 stsp * which last changed this line.
647 16357e96 2019-08-19 stsp * The callback is invoked for each commit as history is traversed.
648 16357e96 2019-08-19 stsp - * If no changes to the file were made in a commit, line number -1 and
649 16357e96 2019-08-19 stsp - * commit ID NULL will be reported.
650 16357e96 2019-08-19 stsp + * If no changes to the file were made in a commit, line number -1 will
651 16357e96 2019-08-19 stsp + * be reported.
653 16357e96 2019-08-19 stsp * If the callback returns GOT_ERR_ITER_COMPLETED, the blame operation
654 16357e96 2019-08-19 stsp * will be aborted and this function returns NULL.
656 16357e96 2019-08-19 stsp (cd $testroot/wt && patch < blame-4.patch > /dev/null)
657 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 4" > /dev/null)
659 16357e96 2019-08-19 stsp cat > $testroot/wt/blame-5.patch <<EOF
660 16357e96 2019-08-19 stsp diff 28315671b93d195163b0468fcb3879e29b25759c e27a7222faaa171dcb086ea0b566dc7bebb74a0b
661 16357e96 2019-08-19 stsp blob - 39623c468e733ee08abb50eafe29202b2b0a04ef
662 16357e96 2019-08-19 stsp blob + 6075cadbd177e1802679c7353515bf4ceebb51d0
663 16357e96 2019-08-19 stsp --- got_blame.h
664 16357e96 2019-08-19 stsp +++ got_blame.h
665 16357e96 2019-08-19 stsp @@ -15,14 +15,7 @@
669 16357e96 2019-08-19 stsp - * Write an annotated version of a file at a given in-repository path,
670 16357e96 2019-08-19 stsp - * as found in the commit specified by ID, to the specified output file.
672 16357e96 2019-08-19 stsp -const struct got_error *got_blame(const char *, struct got_object_id *,
673 16357e96 2019-08-19 stsp - struct got_repository *, FILE *);
676 16357e96 2019-08-19 stsp - * Like got_blame() but instead of generating an output file invoke
677 16357e96 2019-08-19 stsp + * Blame the blob at the specified path in the specified commit and invoke
678 16357e96 2019-08-19 stsp * a callback whenever an annotation has been computed for a line.
680 16357e96 2019-08-19 stsp * The callback receives the provided void * argument, the total number
682 16357e96 2019-08-19 stsp (cd $testroot/wt && patch < blame-5.patch > /dev/null)
683 16357e96 2019-08-19 stsp (cd $testroot/wt && got commit -m "change 5" > /dev/null)
685 4c9641fd 2019-08-21 stsp blame_cmp "$testroot" "got_blame.h"
687 8d725ae1 2019-08-18 stsp test_done "$testroot" "$ret"
690 f6cae3ed 2020-09-13 naddy test_blame_added_on_branch() {
691 db32465d 2020-02-07 stsp local testroot=`test_init blame_added_on_branch`
693 db32465d 2020-02-07 stsp got branch -r $testroot/repo -c master newbranch
695 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
696 db32465d 2020-02-07 stsp test_done "$testroot" "$ret"
700 db32465d 2020-02-07 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
702 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
703 db32465d 2020-02-07 stsp test_done "$testroot" "$ret"
707 db32465d 2020-02-07 stsp echo 1 > $testroot/wt/new
708 db32465d 2020-02-07 stsp (cd $testroot/wt && got add new > /dev/null)
709 db32465d 2020-02-07 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
710 db32465d 2020-02-07 stsp local commit1=`git_show_branch_head $testroot/repo newbranch`
712 db32465d 2020-02-07 stsp echo 2 >> $testroot/wt/new
713 db32465d 2020-02-07 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
714 db32465d 2020-02-07 stsp local commit2=`git_show_branch_head $testroot/repo newbranch`
716 db32465d 2020-02-07 stsp echo 3 >> $testroot/wt/new
717 db32465d 2020-02-07 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
718 db32465d 2020-02-07 stsp local commit3=`git_show_branch_head $testroot/repo newbranch`
719 db32465d 2020-02-07 stsp local author_time=`git_show_author_time $testroot/repo`
721 db32465d 2020-02-07 stsp (cd $testroot/wt && got blame new > $testroot/stdout)
723 db32465d 2020-02-07 stsp local short_commit1=`trim_obj_id 32 $commit1`
724 db32465d 2020-02-07 stsp local short_commit2=`trim_obj_id 32 $commit2`
725 db32465d 2020-02-07 stsp local short_commit3=`trim_obj_id 32 $commit3`
727 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
728 db32465d 2020-02-07 stsp echo "1) $short_commit1 $d $GOT_AUTHOR_8 1" > $testroot/stdout.expected
729 db32465d 2020-02-07 stsp echo "2) $short_commit2 $d $GOT_AUTHOR_8 2" >> $testroot/stdout.expected
730 db32465d 2020-02-07 stsp echo "3) $short_commit3 $d $GOT_AUTHOR_8 3" >> $testroot/stdout.expected
732 db32465d 2020-02-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
734 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
735 db32465d 2020-02-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
737 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
740 f6cae3ed 2020-09-13 naddy test_blame_submodule() {
741 e7303626 2020-05-14 stsp local testroot=`test_init blame_submodule`
742 e7303626 2020-05-14 stsp local commit_id0=`git_show_head $testroot/repo`
743 e7303626 2020-05-14 stsp local author_time=`git_show_author_time $testroot/repo`
745 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
747 f73bf5bd 2023-10-01 naddy git -C $testroot/repo -c protocol.file.allow=always \
748 f73bf5bd 2023-10-01 naddy submodule -q add ../repo2
749 f73bf5bd 2023-10-01 naddy git -C $testroot/repo commit -q -m 'adding submodule'
751 e7303626 2020-05-14 stsp # Attempt a (nonsensical) blame of a submodule.
752 e7303626 2020-05-14 stsp got blame -r $testroot/repo repo2 \
753 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
755 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
756 e7303626 2020-05-14 stsp echo "blame command succeeded unexpectedly" >&2
757 e7303626 2020-05-14 stsp test_done "$testroot" "1"
760 e7303626 2020-05-14 stsp local submodule_id=$(got tree -r $testroot/repo -i | \
761 e7303626 2020-05-14 stsp grep 'repo2\$$' | cut -d ' ' -f1)
762 e7303626 2020-05-14 stsp echo "got: object $submodule_id not found" > $testroot/stderr.expected
764 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
766 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
767 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
769 db32465d 2020-02-07 stsp test_done "$testroot" "$ret"
772 f6cae3ed 2020-09-13 naddy test_blame_symlink() {
773 0587e10c 2020-07-23 stsp local testroot=`test_init blame_symlink`
774 0587e10c 2020-07-23 stsp local commit_id0=`git_show_head $testroot/repo`
775 0587e10c 2020-07-23 stsp local short_commit0=`trim_obj_id 32 $commit_id0`
777 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
778 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
779 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
780 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
781 0587e10c 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
782 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add .
783 0587e10c 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
785 0587e10c 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
786 0587e10c 2020-07-23 stsp local short_commit1=`trim_obj_id 32 $commit_id1`
787 0587e10c 2020-07-23 stsp local author_time=`git_show_author_time $testroot/repo`
789 0587e10c 2020-07-23 stsp # got blame dereferences symlink to a regular file
790 0587e10c 2020-07-23 stsp got blame -r $testroot/repo alpha.link > $testroot/stdout
792 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
793 0587e10c 2020-07-23 stsp echo "blame command failed unexpectedly" >&2
794 0587e10c 2020-07-23 stsp test_done "$testroot" "$ret"
798 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
799 0587e10c 2020-07-23 stsp echo "1) $short_commit0 $d $GOT_AUTHOR_8 alpha" \
800 0587e10c 2020-07-23 stsp > $testroot/stdout.expected
802 0587e10c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
804 49c543a6 2022-03-31 naddy if [ $ret -ne 0 -a "$xfail" = "" ]; then
805 0587e10c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
806 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
810 0587e10c 2020-07-23 stsp # got blame dereferences symlink with relative path
811 0587e10c 2020-07-23 stsp got blame -r $testroot/repo epsilon/beta.link > $testroot/stdout
813 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
814 0587e10c 2020-07-23 stsp echo "blame command failed unexpectedly" >&2
815 0587e10c 2020-07-23 stsp test_done "$testroot" "$ret"
819 dc8256b6 2021-08-31 naddy d=`date -u -r $author_time +"%G-%m-%d"`
820 0587e10c 2020-07-23 stsp echo "1) $short_commit0 $d $GOT_AUTHOR_8 beta" \
821 0587e10c 2020-07-23 stsp > $testroot/stdout.expected
823 0587e10c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
825 49c543a6 2022-03-31 naddy if [ $ret -ne 0 -a "$xfail" = "" ]; then
826 0587e10c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
827 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
831 0587e10c 2020-07-23 stsp got blame -r $testroot/repo epsilon.link > $testroot/stdout \
832 0587e10c 2020-07-23 stsp 2> $testroot/stderr
834 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
835 0587e10c 2020-07-23 stsp echo "blame command succeeded unexpectedly" >&2
836 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
840 0587e10c 2020-07-23 stsp # blame dereferences symlink to a directory
841 eb59b6d4 2020-07-23 stsp echo "got: /epsilon: wrong type of object" > $testroot/stderr.expected
842 0587e10c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
844 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
845 0587e10c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
846 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
850 0587e10c 2020-07-23 stsp # got blame fails if symlink target does not exist in repo
851 0587e10c 2020-07-23 stsp got blame -r $testroot/repo passwd.link > $testroot/stdout \
852 0587e10c 2020-07-23 stsp 2> $testroot/stderr
854 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
855 0587e10c 2020-07-23 stsp echo "blame command succeeded unexpectedly" >&2
856 a19f439c 2022-06-03 op test_done "$testroot" "1"
860 0587e10c 2020-07-23 stsp echo "got: /etc/passwd: no such entry found in tree" \
861 0587e10c 2020-07-23 stsp > $testroot/stderr.expected
862 0587e10c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
864 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
865 0587e10c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
866 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
870 0587e10c 2020-07-23 stsp got blame -r $testroot/repo nonexistent.link > $testroot/stdout \
871 0587e10c 2020-07-23 stsp 2> $testroot/stderr
873 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
874 0587e10c 2020-07-23 stsp echo "blame command succeeded unexpectedly" >&2
875 a19f439c 2022-06-03 op test_done "$testroot" "1"
879 0587e10c 2020-07-23 stsp echo "got: /nonexistent: no such entry found in tree" \
880 0587e10c 2020-07-23 stsp > $testroot/stderr.expected
881 0587e10c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
883 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
884 0587e10c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
885 0587e10c 2020-07-23 stsp test_done "$testroot" "1"
889 0587e10c 2020-07-23 stsp test_done "$testroot" "$ret"
892 c27a5e66 2020-11-18 stsp test_blame_lines_shifted_skip() {
893 c27a5e66 2020-11-18 stsp local testroot=`test_init blame_lines_shifted_skip`
895 c27a5e66 2020-11-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
897 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
898 c27a5e66 2020-11-18 stsp test_done "$testroot" "$ret"
902 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
908 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 1" > /dev/null)
909 c27a5e66 2020-11-18 stsp local commit1=`git_show_head $testroot/repo`
910 c27a5e66 2020-11-18 stsp local short_commit1=`trim_obj_id 32 $commit1`
911 ca6354ef 2023-05-12 stsp local author_time1=`git_show_author_time $testroot/repo`
913 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
921 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 2" > /dev/null)
922 c27a5e66 2020-11-18 stsp local commit2=`git_show_head $testroot/repo`
923 c27a5e66 2020-11-18 stsp local short_commit2=`trim_obj_id 32 $commit2`
924 ca6354ef 2023-05-12 stsp local author_time2=`git_show_author_time $testroot/repo`
926 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
935 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 3" > /dev/null)
936 c27a5e66 2020-11-18 stsp local commit3=`git_show_head $testroot/repo`
937 c27a5e66 2020-11-18 stsp local short_commit3=`trim_obj_id 32 $commit3`
938 ca6354ef 2023-05-12 stsp local author_time3=`git_show_author_time $testroot/repo`
940 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
948 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 4" > /dev/null)
949 c27a5e66 2020-11-18 stsp local commit4=`git_show_head $testroot/repo`
950 c27a5e66 2020-11-18 stsp local short_commit4=`trim_obj_id 32 $commit4`
951 ca6354ef 2023-05-12 stsp local author_time4=`git_show_author_time $testroot/repo`
953 c27a5e66 2020-11-18 stsp cat > $testroot/wt/alpha <<EOF
962 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got commit -m "change 5" > /dev/null)
963 c27a5e66 2020-11-18 stsp local commit5=`git_show_head $testroot/repo`
964 c27a5e66 2020-11-18 stsp local short_commit5=`trim_obj_id 32 $commit5`
965 ca6354ef 2023-05-12 stsp local author_time5=`git_show_author_time $testroot/repo`
967 c27a5e66 2020-11-18 stsp (cd $testroot/wt && got blame alpha > $testroot/stdout)
969 ca6354ef 2023-05-12 stsp d1=`date -u -r $author_time1 +"%G-%m-%d"`
970 ca6354ef 2023-05-12 stsp d2=`date -u -r $author_time2 +"%G-%m-%d"`
971 ca6354ef 2023-05-12 stsp d4=`date -u -r $author_time4 +"%G-%m-%d"`
972 ca6354ef 2023-05-12 stsp d5=`date -u -r $author_time5 +"%G-%m-%d"`
973 ca6354ef 2023-05-12 stsp echo "1) $short_commit5 $d5 $GOT_AUTHOR_8 X" > $testroot/stdout.expected
974 ca6354ef 2023-05-12 stsp echo "2) $short_commit1 $d1 $GOT_AUTHOR_8 A" >> $testroot/stdout.expected
975 ca6354ef 2023-05-12 stsp echo "3) $short_commit1 $d1 $GOT_AUTHOR_8 B" >> $testroot/stdout.expected
976 ca6354ef 2023-05-12 stsp echo "4) $short_commit1 $d1 $GOT_AUTHOR_8 C" >> $testroot/stdout.expected
977 ca6354ef 2023-05-12 stsp echo "5) $short_commit2 $d2 $GOT_AUTHOR_8 P" >> $testroot/stdout.expected
978 ca6354ef 2023-05-12 stsp echo "6) $short_commit4 $d4 $GOT_AUTHOR_8 Y" >> $testroot/stdout.expected
979 ca6354ef 2023-05-12 stsp echo "7) $short_commit2 $d5 $GOT_AUTHOR_8 Q" >> $testroot/stdout.expected
981 c27a5e66 2020-11-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
983 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
984 c27a5e66 2020-11-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
985 4390d6c1 2023-07-18 mark test_done "$testroot" "$ret"
989 4390d6c1 2023-07-18 mark blame_cmp "$testroot" "alpha"
991 4390d6c1 2023-07-18 mark test_done "$testroot" "$ret"
994 4390d6c1 2023-07-18 mark test_blame_commit_keywords() {
995 4390d6c1 2023-07-18 mark local testroot=$(test_init blame_commit_keywords)
996 4390d6c1 2023-07-18 mark local repo="$testroot/repo"
997 4390d6c1 2023-07-18 mark local wt="$testroot/wt"
998 4390d6c1 2023-07-18 mark local id=$(git_show_head "$repo")
1000 79c49d84 2023-07-24 mark set -- "$(trim_obj_id 32 $id)"
1002 4390d6c1 2023-07-18 mark # :base requires work tree
1003 4390d6c1 2023-07-18 mark echo "got: '-c :base' requires work tree" > "$testroot/stderr.expected"
1004 4390d6c1 2023-07-18 mark got blame -r "$repo" -c:base alpha 2> "$testroot/stderr"
1006 4390d6c1 2023-07-18 mark if [ $ret -eq 0 ]; then
1007 4390d6c1 2023-07-18 mark echo "blame command succeeded unexpectedly" >&2
1008 4390d6c1 2023-07-18 mark test_done "$testroot" "1"
1012 4390d6c1 2023-07-18 mark cmp -s "$testroot/stderr.expected" "$testroot/stderr"
1014 4390d6c1 2023-07-18 mark if [ $ret -ne 0 ]; then
1015 4390d6c1 2023-07-18 mark diff -u "$testroot/stderr.expected" "$testroot/stderr"
1016 4390d6c1 2023-07-18 mark test_done "$testroot" "$ret"
1020 4390d6c1 2023-07-18 mark got checkout "$repo" "$wt" > /dev/null
1022 4390d6c1 2023-07-18 mark if [ $ret -ne 0 ]; then
1023 4390d6c1 2023-07-18 mark test_done "$testroot" "$ret"
1027 4390d6c1 2023-07-18 mark echo -n > "$wt/alpha"
1029 4390d6c1 2023-07-18 mark for i in $(seq 8); do
1030 4390d6c1 2023-07-18 mark echo "change $i" >> "$wt/alpha"
1032 4390d6c1 2023-07-18 mark (cd "$wt" && got ci -m "commit $i" > /dev/null)
1034 4390d6c1 2023-07-18 mark if [ $ret -ne 0 ]; then
1035 4390d6c1 2023-07-18 mark echo "commit failed unexpectedly" >&2
1036 4390d6c1 2023-07-18 mark test_done "$testroot" "$ret"
1040 4390d6c1 2023-07-18 mark id=$(git_show_head "$repo")
1041 79c49d84 2023-07-24 mark set -- "$@" "$(trim_obj_id 32 $id)"
1044 4390d6c1 2023-07-18 mark local author_time=$(git_show_author_time "$repo")
1045 4390d6c1 2023-07-18 mark local d=$(date -u -r $author_time +"%G-%m-%d")
1047 4390d6c1 2023-07-18 mark got blame -r "$repo" -c:head:-8 alpha > "$testroot/stdout"
1048 79c49d84 2023-07-24 mark echo "1) $(pop_idx 1 $@) $d $GOT_AUTHOR_8 alpha" > \
1049 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1051 4390d6c1 2023-07-18 mark cmp -s $testroot/stdout.expected $testroot/stdout
1053 4390d6c1 2023-07-18 mark if [ $ret -ne 0 ]; then
1054 4390d6c1 2023-07-18 mark diff -u "$testroot/stdout.expected" "$testroot/stdout"
1055 c27a5e66 2020-11-18 stsp test_done "$testroot" "$ret"
1059 4390d6c1 2023-07-18 mark (cd "$wt" && got blame -cmaster:-5 alpha > "$testroot/stdout")
1061 79c49d84 2023-07-24 mark echo "1) $(pop_idx 2 $@) $d $GOT_AUTHOR_8 change 1" > \
1062 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1063 79c49d84 2023-07-24 mark echo "2) $(pop_idx 3 $@) $d $GOT_AUTHOR_8 change 2" >> \
1064 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1065 79c49d84 2023-07-24 mark echo "3) $(pop_idx 4 $@) $d $GOT_AUTHOR_8 change 3" >> \
1066 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1068 4390d6c1 2023-07-18 mark cmp -s $testroot/stdout.expected $testroot/stdout
1070 4390d6c1 2023-07-18 mark if [ $ret -ne 0 ]; then
1071 4390d6c1 2023-07-18 mark diff -u "$testroot/stdout.expected" "$testroot/stdout"
1072 4390d6c1 2023-07-18 mark test_done "$testroot" "$ret"
1076 4390d6c1 2023-07-18 mark (cd "$wt" && got blame -c:head:-4 alpha > "$testroot/stdout")
1078 79c49d84 2023-07-24 mark echo "1) $(pop_idx 2 $@) $d $GOT_AUTHOR_8 change 1" > \
1079 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1080 79c49d84 2023-07-24 mark echo "2) $(pop_idx 3 $@) $d $GOT_AUTHOR_8 change 2" >> \
1081 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1082 79c49d84 2023-07-24 mark echo "3) $(pop_idx 4 $@) $d $GOT_AUTHOR_8 change 3" >> \
1083 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1084 79c49d84 2023-07-24 mark echo "4) $(pop_idx 5 $@) $d $GOT_AUTHOR_8 change 4" >> \
1085 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1087 4390d6c1 2023-07-18 mark cmp -s $testroot/stdout.expected $testroot/stdout
1089 4390d6c1 2023-07-18 mark if [ $ret -ne 0 ]; then
1090 4390d6c1 2023-07-18 mark diff -u "$testroot/stdout.expected" "$testroot/stdout"
1091 4390d6c1 2023-07-18 mark test_done "$testroot" "$ret"
1095 4390d6c1 2023-07-18 mark (cd "$wt" && got up -c:head:-8 > /dev/null)
1096 4390d6c1 2023-07-18 mark (cd "$wt" && got blame -c:base:+5 alpha > "$testroot/stdout")
1098 79c49d84 2023-07-24 mark echo "1) $(pop_idx 2 $@) $d $GOT_AUTHOR_8 change 1" > \
1099 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1100 79c49d84 2023-07-24 mark echo "2) $(pop_idx 3 $@) $d $GOT_AUTHOR_8 change 2" >> \
1101 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1102 79c49d84 2023-07-24 mark echo "3) $(pop_idx 4 $@) $d $GOT_AUTHOR_8 change 3" >> \
1103 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1104 79c49d84 2023-07-24 mark echo "4) $(pop_idx 5 $@) $d $GOT_AUTHOR_8 change 4" >> \
1105 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1106 79c49d84 2023-07-24 mark echo "5) $(pop_idx 6 $@) $d $GOT_AUTHOR_8 change 5" >> \
1107 4390d6c1 2023-07-18 mark "$testroot/stdout.expected"
1109 4390d6c1 2023-07-18 mark cmp -s $testroot/stdout.expected $testroot/stdout
1111 4390d6c1 2023-07-18 mark if [ $ret -ne 0 ]; then
1112 4390d6c1 2023-07-18 mark diff -u "$testroot/stdout.expected" "$testroot/stdout"
1113 4390d6c1 2023-07-18 mark test_done "$testroot" "$ret"
1117 c27a5e66 2020-11-18 stsp blame_cmp "$testroot" "alpha"
1119 c27a5e66 2020-11-18 stsp test_done "$testroot" "$ret"
1122 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1123 c970ea82 2019-07-27 stsp run_test test_blame_basic
1124 303e2782 2019-08-09 stsp run_test test_blame_tag
1125 78695fb7 2019-08-12 stsp run_test test_blame_file_single_line
1126 78695fb7 2019-08-12 stsp run_test test_blame_file_single_line_no_newline
1127 8d725ae1 2019-08-18 stsp run_test test_blame_all_lines_replaced
1128 8d725ae1 2019-08-18 stsp run_test test_blame_lines_shifted_up
1129 8d725ae1 2019-08-18 stsp run_test test_blame_lines_shifted_down
1130 8d725ae1 2019-08-18 stsp run_test test_blame_commit_subsumed
1131 16357e96 2019-08-19 stsp run_test test_blame_blame_h
1132 db32465d 2020-02-07 stsp run_test test_blame_added_on_branch
1133 e7303626 2020-05-14 stsp run_test test_blame_submodule
1134 0587e10c 2020-07-23 stsp run_test test_blame_symlink
1135 c27a5e66 2020-11-18 stsp run_test test_blame_lines_shifted_skip
1136 4390d6c1 2023-07-18 mark run_test test_blame_commit_keywords