Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ./common.sh
19 test_log_in_repo() {
20 local testroot=`test_init log_in_repo`
21 local head_rev=`git_show_head $testroot/repo`
23 echo "commit $head_rev (master)" > $testroot/stdout.expected
25 for p in "" "." alpha epsilon epsilon/zeta; do
26 (cd $testroot/repo && got log $p | \
27 grep ^commit > $testroot/stdout)
28 cmp -s $testroot/stdout.expected $testroot/stdout
29 ret=$?
30 if [ $ret -ne 0 ]; then
31 diff -u $testroot/stdout.expected $testroot/stdout
32 test_done "$testroot" "$ret"
33 return 1
34 fi
35 done
37 for p in "" "." zeta; do
38 (cd $testroot/repo/epsilon && got log $p | \
39 grep ^commit > $testroot/stdout)
40 cmp -s $testroot/stdout.expected $testroot/stdout
41 ret=$?
42 if [ $ret -ne 0 ]; then
43 diff -u $testroot/stdout.expected $testroot/stdout
44 test_done "$testroot" "$ret"
45 return 1
46 fi
47 done
49 test_done "$testroot" "0"
50 }
52 test_log_in_bare_repo() {
53 local testroot=`test_init log_in_bare_repo`
54 local head_rev=`git_show_head $testroot/repo`
56 echo "commit $head_rev (master)" > $testroot/stdout.expected
58 for p in "" "." alpha epsilon epsilon/zeta; do
59 (cd $testroot/repo/.git && got log $p | \
60 grep ^commit > $testroot/stdout)
61 cmp -s $testroot/stdout.expected $testroot/stdout
62 ret=$?
63 if [ $ret -ne 0 ]; then
64 diff -u $testroot/stdout.expected $testroot/stdout
65 test_done "$testroot" "$ret"
66 return 1
67 fi
68 done
70 test_done "$testroot" "0"
71 }
73 test_log_in_worktree() {
74 local testroot=`test_init log_in_worktree 1`
76 make_test_tree $testroot/repo
77 mkdir -p $testroot/repo/epsilon/d
78 echo foo > $testroot/repo/epsilon/d/foo
79 git -C $testroot/repo add .
80 git_commit $testroot/repo -m "adding the test tree"
81 local head_commit=`git_show_head $testroot/repo`
83 got checkout $testroot/repo $testroot/wt > /dev/null
84 ret=$?
85 if [ $ret -ne 0 ]; then
86 test_done "$testroot" "$ret"
87 return 1
88 fi
90 echo "commit $head_commit (master)" > $testroot/stdout.expected
92 for p in "" "." alpha epsilon; do
93 (cd $testroot/wt && got log $p | \
94 grep ^commit > $testroot/stdout)
95 cmp -s $testroot/stdout.expected $testroot/stdout
96 ret=$?
97 if [ $ret -ne 0 ]; then
98 diff -u $testroot/stdout.expected $testroot/stdout
99 test_done "$testroot" "$ret"
100 return 1
101 fi
102 done
104 for p in "" "." zeta; do
105 (cd $testroot/wt/epsilon && got log $p | \
106 grep ^commit > $testroot/stdout)
107 cmp -s $testroot/stdout.expected $testroot/stdout
108 ret=$?
109 if [ $ret -ne 0 ]; then
110 diff -u $testroot/stdout.expected $testroot/stdout
111 test_done "$testroot" "$ret"
112 return 1
113 fi
114 done
116 for p in "" "." foo; do
117 (cd $testroot/wt/epsilon && got log d/$p | \
118 grep ^commit > $testroot/stdout)
119 cmp -s $testroot/stdout.expected $testroot/stdout
120 ret=$?
121 if [ $ret -ne 0 ]; then
122 diff -u $testroot/stdout.expected $testroot/stdout
123 test_done "$testroot" "$ret"
124 return 1
125 fi
126 done
128 test_done "$testroot" "0"
131 test_log_in_worktree_with_path_prefix() {
132 local testroot=`test_init log_in_worktree_with_path_prefix`
133 local head_rev=`git_show_head $testroot/repo`
135 echo "modified zeta" > $testroot/repo/epsilon/zeta
136 git_commit $testroot/repo -m "modified zeta"
137 local zeta_rev=`git_show_head $testroot/repo`
139 echo "modified delta" > $testroot/repo/gamma/delta
140 git_commit $testroot/repo -m "modified delta"
141 local delta_rev=`git_show_head $testroot/repo`
143 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
144 ret=$?
145 if [ $ret -ne 0 ]; then
146 test_done "$testroot" "$ret"
147 return 1
148 fi
150 echo "commit $delta_rev (master)" > $testroot/stdout.expected
151 echo "commit $zeta_rev" >> $testroot/stdout.expected
152 echo "commit $head_rev" >> $testroot/stdout.expected
154 (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
155 cmp -s $testroot/stdout.expected $testroot/stdout
156 ret=$?
157 if [ $ret -ne 0 ]; then
158 diff -u $testroot/stdout.expected $testroot/stdout
159 test_done "$testroot" "$ret"
160 return 1
161 fi
163 echo "commit $zeta_rev" > $testroot/stdout.expected
164 echo "commit $head_rev" >> $testroot/stdout.expected
166 for p in "." zeta; do
167 (cd $testroot/wt && got log $p | \
168 grep ^commit > $testroot/stdout)
169 cmp -s $testroot/stdout.expected $testroot/stdout
170 ret=$?
171 if [ $ret -ne 0 ]; then
172 diff -u $testroot/stdout.expected $testroot/stdout
173 test_done "$testroot" "$ret"
174 return 1
175 fi
176 done
178 test_done "$testroot" "0"
181 test_log_tag() {
182 local testroot=`test_init log_tag`
183 local commit_id=`git_show_head $testroot/repo`
184 local tag="1.0.0"
185 local tag2="2.0.0"
187 got checkout $testroot/repo $testroot/wt > /dev/null
188 ret=$?
189 if [ $ret -ne 0 ]; then
190 test_done "$testroot" "$ret"
191 return 1
192 fi
194 git -C $testroot/repo tag -a -m "test" $tag
196 echo "commit $commit_id (master, tags/$tag)" > $testroot/stdout.expected
197 (cd $testroot/wt && got log -l1 -c $tag | grep ^commit \
198 > $testroot/stdout)
199 cmp -s $testroot/stdout.expected $testroot/stdout
200 ret=$?
201 if [ $ret -ne 0 ]; then
202 diff -u $testroot/stdout.expected $testroot/stdout
203 test_done "$testroot" "$ret"
204 return 1
205 fi
207 # test a "lightweight" tag
208 git -C $testroot/repo tag $tag2
210 echo "commit $commit_id (master, tags/$tag, tags/$tag2)" \
211 > $testroot/stdout.expected
212 (cd $testroot/wt && got log -l1 -c $tag2 | grep ^commit \
213 > $testroot/stdout)
214 cmp -s $testroot/stdout.expected $testroot/stdout
215 ret=$?
216 if [ $ret -ne 0 ]; then
217 diff -u $testroot/stdout.expected $testroot/stdout
218 fi
219 test_done "$testroot" "$ret"
222 test_log_limit() {
223 local testroot=`test_init log_limit`
224 local commit_id0=`git_show_head $testroot/repo`
226 got checkout $testroot/repo $testroot/wt > /dev/null
227 ret=$?
228 if [ $ret -ne 0 ]; then
229 test_done "$testroot" "$ret"
230 return 1
231 fi
233 echo "modified alpha" > $testroot/wt/alpha
234 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
235 local commit_id1=`git_show_head $testroot/repo`
237 (cd $testroot/wt && got rm beta >/dev/null)
238 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
239 local commit_id2=`git_show_head $testroot/repo`
241 echo "new file" > $testroot/wt/new
242 (cd $testroot/wt && got add new >/dev/null)
243 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
244 local commit_id3=`git_show_head $testroot/repo`
246 # -l1 should print the first commit only
247 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
248 (cd $testroot/wt && got log -l1 | grep ^commit > $testroot/stdout)
249 cmp -s $testroot/stdout.expected $testroot/stdout
250 ret=$?
251 if [ $ret -ne 0 ]; then
252 diff -u $testroot/stdout.expected $testroot/stdout
253 test_done "$testroot" "$ret"
254 return 1
255 fi
257 # env var can be used to set a log limit without -l option
258 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
259 echo "commit $commit_id2" >> $testroot/stdout.expected
260 (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=2 got log | \
261 grep ^commit > $testroot/stdout)
262 cmp -s $testroot/stdout.expected $testroot/stdout
263 ret=$?
264 if [ $ret -ne 0 ]; then
265 diff -u $testroot/stdout.expected $testroot/stdout
266 test_done "$testroot" "$ret"
267 return 1
268 fi
270 # non-numeric env var is ignored
271 (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=foobar got log | \
272 grep ^commit > $testroot/stdout)
273 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
274 echo "commit $commit_id2" >> $testroot/stdout.expected
275 echo "commit $commit_id1" >> $testroot/stdout.expected
276 echo "commit $commit_id0" >> $testroot/stdout.expected
277 cmp -s $testroot/stdout.expected $testroot/stdout
278 ret=$?
279 if [ $ret -ne 0 ]; then
280 diff -u $testroot/stdout.expected $testroot/stdout
281 test_done "$testroot" "$ret"
282 return 1
283 fi
285 # -l option takes precedence over env var
286 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
287 echo "commit $commit_id2" >> $testroot/stdout.expected
288 echo "commit $commit_id1" >> $testroot/stdout.expected
289 echo "commit $commit_id0" >> $testroot/stdout.expected
290 (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=1 got log -l0 | \
291 grep ^commit > $testroot/stdout)
292 cmp -s $testroot/stdout.expected $testroot/stdout
293 ret=$?
294 if [ $ret -ne 0 ]; then
295 diff -u $testroot/stdout.expected $testroot/stdout
296 fi
297 test_done "$testroot" "0"
300 test_log_oneline() {
301 local testroot=`test_init log_oneline`
302 local commit_id0=`git_show_head $testroot/repo`
303 got checkout $testroot/repo $testroot/wt > /dev/null
304 ret=$?
305 if [ $ret -ne 0 ]; then
306 test_done "$testroot" "$ret"
307 return 1
308 fi
310 echo "modified alpha" > $testroot/wt/alpha
311 (cd $testroot/wt && got commit -m "test oneline
312 no" > /dev/null)
313 local commit_id1=`git_show_head $testroot/repo`
314 local author_time1=`git_show_author_time $testroot/repo`
316 echo "modified beta" > $testroot/wt/beta
317 (cd $testroot/wt && got commit -m " test oneline
318 no" > /dev/null)
319 local commit_id2=`git_show_head $testroot/repo`
320 local author_time2=`git_show_author_time $testroot/repo`
322 d=`date -u -r $author_time1 +"%G-%m-%d"`
323 printf "$d %-7s test oneline\n" master > $testroot/stdout.expected
324 d=`date -u -r $author_time2 +"%G-%m-%d"`
325 printf "$d %.7s test oneline\n" $commit_id1 >> $testroot/stdout.expected
327 (cd $testroot/repo && got log -s | head -n 2 > $testroot/stdout)
328 cmp -s $testroot/stdout.expected $testroot/stdout
329 ret=$?
330 if [ $ret -ne 0 ]; then
331 diff -u $testroot/stdout.expected $testroot/stdout
332 test_done "$testroot" "$ret"
333 return 1
334 fi
335 test_done "$testroot" "0"
338 test_log_patch_added_file() {
339 local testroot=`test_init log_patch_added_file`
340 local commit_id0=`git_show_head $testroot/repo`
342 got checkout $testroot/repo $testroot/wt > /dev/null
343 ret=$?
344 if [ $ret -ne 0 ]; then
345 test_done "$testroot" "$ret"
346 return 1
347 fi
349 echo "new file" > $testroot/wt/new
350 (cd $testroot/wt && got add new >/dev/null)
351 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
352 local commit_id1=`git_show_head $testroot/repo`
354 echo "commit $commit_id1 (master)" > $testroot/stdout.expected
355 echo "commit - $commit_id0" >> $testroot/stdout.expected
356 echo "commit + $commit_id1" >> $testroot/stdout.expected
357 # This used to fail with 'got: no such entry found in tree'
358 (cd $testroot/wt && got log -l1 -p new > $testroot/stdout.patch)
359 ret=$?
360 if [ $ret -ne 0 ]; then
361 echo "got log command failed unexpectedly" >&2
362 test_done "$testroot" "$ret"
363 return 1
364 fi
365 grep ^commit $testroot/stdout.patch > $testroot/stdout
366 cmp -s $testroot/stdout.expected $testroot/stdout
367 ret=$?
368 if [ $ret -ne 0 ]; then
369 diff -u $testroot/stdout.expected $testroot/stdout
370 fi
371 test_done "$testroot" "$ret"
374 test_log_nonexistent_path() {
375 local testroot=`test_init log_nonexistent_path`
376 local head_rev=`git_show_head $testroot/repo`
378 echo "commit $head_rev (master)" > $testroot/stdout.expected
380 (cd $testroot/repo && got log this/does/not/exist \
381 > $testroot/stdout 2> $testroot/stderr)
382 ret=$?
383 if [ $ret -eq 0 ]; then
384 echo "log command succeeded unexpectedly" >&2
385 test_done "$testroot" "1"
386 return 1
387 fi
389 echo -n > $testroot/stdout.expected
390 cmp -s $testroot/stdout.expected $testroot/stdout
391 ret=$?
392 if [ $ret -ne 0 ]; then
393 diff -u $testroot/stdout.expected $testroot/stdout
394 test_done "$testroot" "$ret"
395 return 1
396 fi
398 echo "got: this/does/not/exist: no such entry found in tree" \
399 > $testroot/stderr.expected
400 cmp -s $testroot/stderr.expected $testroot/stderr
401 ret=$?
402 if [ $ret -ne 0 ]; then
403 diff -u $testroot/stderr.expected $testroot/stderr
404 fi
405 test_done "$testroot" "$ret"
408 test_log_end_at_commit() {
409 local testroot=`test_init log_end_at_commit`
410 local commit_id0=`git_show_head $testroot/repo`
412 got checkout $testroot/repo $testroot/wt > /dev/null
413 ret=$?
414 if [ $ret -ne 0 ]; then
415 test_done "$testroot" "$ret"
416 return 1
417 fi
419 echo "modified alpha" > $testroot/wt/alpha
420 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
421 local commit_id1=`git_show_head $testroot/repo`
423 (cd $testroot/wt && got rm beta >/dev/null)
424 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
425 local commit_id2=`git_show_head $testroot/repo`
427 echo "new file" > $testroot/wt/new
428 (cd $testroot/wt && got add new >/dev/null)
429 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
430 local commit_id3=`git_show_head $testroot/repo`
432 # Print commit 3 only
433 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
434 (cd $testroot/wt && got log -x $commit_id3 | grep ^commit \
435 > $testroot/stdout)
436 cmp -s $testroot/stdout.expected $testroot/stdout
437 ret=$?
438 if [ $ret -ne 0 ]; then
439 diff -u $testroot/stdout.expected $testroot/stdout
440 test_done "$testroot" "$ret"
441 return 1
442 fi
444 # Print commit 3 up to commit 1 inclusive
445 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
446 echo "commit $commit_id2" >> $testroot/stdout.expected
447 echo "commit $commit_id1" >> $testroot/stdout.expected
448 (cd $testroot/wt && got log -c $commit_id3 -x $commit_id1 | \
449 grep ^commit > $testroot/stdout)
450 cmp -s $testroot/stdout.expected $testroot/stdout
451 ret=$?
452 if [ $ret -ne 0 ]; then
453 diff -u $testroot/stdout.expected $testroot/stdout
454 test_done "$testroot" "$ret"
455 return 1
456 fi
458 # Create commits on an unrelated branch
459 (cd $testroot/wt && got br foo > /dev/null)
460 echo bar >> $testroot/wt/alpha
461 (cd $testroot/wt && got commit -m "change on branch foo" >/dev/null)
462 local commit_id4=`git_show_branch_head $testroot/repo foo`
464 # Print commit 4 only (in work tree)
465 echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
466 (cd $testroot/wt && got log -x foo | grep ^commit \
467 > $testroot/stdout)
468 cmp -s $testroot/stdout.expected $testroot/stdout
469 ret=$?
470 if [ $ret -ne 0 ]; then
471 diff -u $testroot/stdout.expected $testroot/stdout
472 test_done "$testroot" "$ret"
473 return 1
474 fi
476 # Print commit 4 only (in repository)
477 echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
478 (cd $testroot/repo && got log -c foo -x foo | grep ^commit \
479 > $testroot/stdout)
480 cmp -s $testroot/stdout.expected $testroot/stdout
481 ret=$?
482 if [ $ret -ne 0 ]; then
483 diff -u $testroot/stdout.expected $testroot/stdout
484 test_done "$testroot" "$ret"
485 return 1
486 fi
488 # Repository's HEAD is on master branch so -x foo without an explicit
489 # '-c foo' start commit has no effect there
490 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
491 echo "commit $commit_id2" >> $testroot/stdout.expected
492 echo "commit $commit_id1" >> $testroot/stdout.expected
493 echo "commit $commit_id0" >> $testroot/stdout.expected
494 (cd $testroot/repo && got log -x foo | grep ^commit \
495 > $testroot/stdout)
496 cmp -s $testroot/stdout.expected $testroot/stdout
497 ret=$?
498 if [ $ret -ne 0 ]; then
499 diff -u $testroot/stdout.expected $testroot/stdout
500 test_done "$testroot" "$ret"
501 return 1
502 fi
504 # got will refuse -x with a non-existent commit
505 (cd $testroot/wt && got log -x nonexistent \
506 > $testroot/stdout 2> $testroot/stderr)
507 ret=$?
508 if [ $ret -eq 0 ]; then
509 echo "log command succeeded unexpectedly" >&2
510 test_done "$testroot" "1"
511 return 1
512 fi
513 echo -n > $testroot/stdout.expected
514 echo "got: reference nonexistent not found" \
515 > $testroot/stderr.expected
516 cmp -s $testroot/stderr.expected $testroot/stderr
517 ret=$?
518 if [ $ret -ne 0 ]; then
519 diff -u $testroot/stderr.expected $testroot/stderr
520 test_done "$testroot" "$ret"
521 return 1
522 fi
523 cmp -s $testroot/stdout.expected $testroot/stdout
524 ret=$?
525 if [ $ret -ne 0 ]; then
526 diff -u $testroot/stdout.expected $testroot/stdout
527 test_done "$testroot" "$ret"
528 return 1
529 fi
531 # try the same with the hash of an empty string which is very
532 # unlikely to match any object
533 local empty_sha1=da39a3ee5e6b4b0d3255bfef95601890afd80709
534 (cd $testroot/wt && got log -x $empty_sha1 \
535 > $testroot/stdout 2> $testroot/stderr)
536 ret=$?
537 if [ $ret -eq 0 ]; then
538 echo "log command succeeded unexpectedly" >&2
539 test_done "$testroot" "1"
540 return 1
541 fi
542 echo -n > $testroot/stdout.expected
543 echo "got: commit $empty_sha1: object not found" \
544 > $testroot/stderr.expected
545 cmp -s $testroot/stderr.expected $testroot/stderr
546 ret=$?
547 if [ $ret -ne 0 ]; then
548 diff -u $testroot/stderr.expected $testroot/stderr
549 test_done "$testroot" "$ret"
550 return 1
551 fi
552 cmp -s $testroot/stdout.expected $testroot/stdout
553 ret=$?
554 if [ $ret -ne 0 ]; then
555 diff -u $testroot/stdout.expected $testroot/stdout
556 test_done "$testroot" "$ret"
557 return 1
558 fi
560 test_done "$testroot" "0"
563 test_log_reverse_display() {
564 local testroot=`test_init log_reverse_display`
565 local commit_id0=`git_show_head $testroot/repo`
567 got checkout $testroot/repo $testroot/wt > /dev/null
568 ret=$?
569 if [ $ret -ne 0 ]; then
570 test_done "$testroot" "$ret"
571 return 1
572 fi
574 echo "modified alpha" > $testroot/wt/alpha
575 (cd $testroot/wt && got commit -m 'commit1' > /dev/null)
576 local commit_id1=`git_show_head $testroot/repo`
578 (cd $testroot/wt && got rm beta >/dev/null)
579 (cd $testroot/wt && got commit -m 'commit2' > /dev/null)
580 local commit_id2=`git_show_head $testroot/repo`
582 echo "new file" > $testroot/wt/new
583 (cd $testroot/wt && got add new >/dev/null)
584 (cd $testroot/wt && got commit -m 'commit3' > /dev/null)
585 local commit_id3=`git_show_head $testroot/repo`
587 # -R alone should display all commits in reverse
588 echo "commit $commit_id0" > $testroot/stdout.expected
589 echo "commit $commit_id1" >> $testroot/stdout.expected
590 echo "commit $commit_id2" >> $testroot/stdout.expected
591 echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
592 (cd $testroot/wt && got log -R | grep ^commit > $testroot/stdout)
593 cmp -s $testroot/stdout.expected $testroot/stdout
594 ret=$?
595 if [ $ret -ne 0 ]; then
596 diff -u $testroot/stdout.expected $testroot/stdout
597 test_done "$testroot" "$ret"
598 return 1
599 fi
601 # -R takes effect after the -l commit traversal limit
602 echo "commit $commit_id2" > $testroot/stdout.expected
603 echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
604 (cd $testroot/wt && got log -R -l2 | grep ^commit > $testroot/stdout)
605 cmp -s $testroot/stdout.expected $testroot/stdout
606 ret=$?
607 if [ $ret -ne 0 ]; then
608 diff -u $testroot/stdout.expected $testroot/stdout
609 test_done "$testroot" "$ret"
610 return 1
611 fi
613 # -R works with commit ranges specified via -c and -x
614 echo "commit $commit_id1" > $testroot/stdout.expected
615 echo "commit $commit_id2" >> $testroot/stdout.expected
616 echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
617 (cd $testroot/wt && got log -R -c $commit_id3 -x $commit_id1 | \
618 grep ^commit > $testroot/stdout)
619 cmp -s $testroot/stdout.expected $testroot/stdout
620 ret=$?
621 if [ $ret -ne 0 ]; then
622 diff -u $testroot/stdout.expected $testroot/stdout
623 test_done "$testroot" "$ret"
624 return 1
625 fi
627 # commit matching with -s applies before -R
628 echo "commit $commit_id1" > $testroot/stdout.expected
629 echo "commit $commit_id2" >> $testroot/stdout.expected
630 (cd $testroot/wt && got log -R -S 'commit[12]' | \
631 grep ^commit > $testroot/stdout)
632 cmp -s $testroot/stdout.expected $testroot/stdout
633 ret=$?
634 if [ $ret -ne 0 ]; then
635 diff -u $testroot/stdout.expected $testroot/stdout
636 test_done "$testroot" "$ret"
637 return 1
638 fi
640 # -R works in combination with -P
641 echo "" > $testroot/stdout.expected
642 (cd $testroot/wt && got log -R -P | grep -E '^(commit| [MDmA])' \
643 > $testroot/stdout)
644 echo "commit $commit_id0" > $testroot/stdout.expected
645 echo " A alpha" >> $testroot/stdout.expected
646 echo " A beta" >> $testroot/stdout.expected
647 echo " A epsilon/zeta" >> $testroot/stdout.expected
648 echo " A gamma/delta" >> $testroot/stdout.expected
649 echo "commit $commit_id1" >> $testroot/stdout.expected
650 echo " M alpha" >> $testroot/stdout.expected
651 echo "commit $commit_id2" >> $testroot/stdout.expected
652 echo " D beta" >> $testroot/stdout.expected
653 echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
654 echo " A new" >> $testroot/stdout.expected
655 cmp -s $testroot/stdout.expected $testroot/stdout
656 ret=$?
657 if [ $ret -ne 0 ]; then
658 diff -u $testroot/stdout.expected $testroot/stdout
659 fi
660 test_done "$testroot" "$ret"
663 test_log_in_worktree_different_repo() {
664 local testroot=`test_init log_in_worktree_different_repo 1`
666 make_test_tree $testroot/repo
667 mkdir -p $testroot/repo/epsilon/d
668 echo foo > $testroot/repo/epsilon/d/foo
669 git -C $testroot/repo add .
670 git_commit $testroot/repo -m "adding the test tree"
671 local head_commit=`git_show_head $testroot/repo`
673 gotadmin init $testroot/other-repo
674 mkdir -p $testroot/tree
675 make_test_tree $testroot/tree
676 got import -mm -b foo -r $testroot/other-repo $testroot/tree >/dev/null
677 got checkout -b foo $testroot/other-repo $testroot/wt > /dev/null
678 ret=$?
679 if [ $ret -ne 0 ]; then
680 test_done "$testroot" "$ret"
681 return 1
682 fi
684 echo "commit $head_commit (master)" > $testroot/stdout.expected
686 # 'got log' used to fail with "reference refs/heads/foo not found"
687 # even though that reference belongs to an unrelated repository
688 # found via a worktree via the current working directory
689 for p in "" alpha epsilon; do
690 (cd $testroot/wt && got log -r $testroot/repo $p | \
691 grep ^commit > $testroot/stdout)
692 cmp -s $testroot/stdout.expected $testroot/stdout
693 ret=$?
694 if [ $ret -ne 0 ]; then
695 diff -u $testroot/stdout.expected $testroot/stdout
696 test_done "$testroot" "$ret"
697 return 1
698 fi
699 done
701 for p in "" epsilon/zeta; do
702 (cd $testroot/wt/epsilon && got log -r $testroot/repo $p | \
703 grep ^commit > $testroot/stdout)
704 cmp -s $testroot/stdout.expected $testroot/stdout
705 ret=$?
706 if [ $ret -ne 0 ]; then
707 diff -u $testroot/stdout.expected $testroot/stdout
708 test_done "$testroot" "$ret"
709 return 1
710 fi
711 done
713 for p in "" foo; do
714 (cd $testroot/wt/epsilon && got log -r $testroot/repo epsilon/d/$p | \
715 grep ^commit > $testroot/stdout)
716 cmp -s $testroot/stdout.expected $testroot/stdout
717 ret=$?
718 if [ $ret -ne 0 ]; then
719 diff -u $testroot/stdout.expected $testroot/stdout
720 test_done "$testroot" "$ret"
721 return 1
722 fi
723 done
725 test_done "$testroot" "0"
728 test_log_changed_paths() {
729 local testroot=`test_init log_changed_paths`
730 local commit_id0=`git_show_head $testroot/repo`
732 got checkout $testroot/repo $testroot/wt > /dev/null
733 ret=$?
734 if [ $ret -ne 0 ]; then
735 test_done "$testroot" "$ret"
736 return 1
737 fi
739 echo "modified alpha" > $testroot/wt/alpha
740 (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
741 local commit_id1=`git_show_head $testroot/repo`
743 (cd $testroot/wt && got rm beta >/dev/null)
744 (cd $testroot/wt && chmod +x epsilon/zeta >/dev/null)
745 (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
746 local commit_id2=`git_show_head $testroot/repo`
748 echo "new file" > $testroot/wt/new
749 (cd $testroot/wt && got add new >/dev/null)
750 (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
751 local commit_id3=`git_show_head $testroot/repo`
753 (cd $testroot/wt && got log -P | grep '^ [MDmA]' > $testroot/stdout)
755 echo " A new" > $testroot/stdout.expected
756 echo " D beta" >> $testroot/stdout.expected
757 echo " m epsilon/zeta" >> $testroot/stdout.expected
758 echo " M alpha" >> $testroot/stdout.expected
759 echo " A alpha" >> $testroot/stdout.expected
760 echo " A beta" >> $testroot/stdout.expected
761 echo " A epsilon/zeta" >> $testroot/stdout.expected
762 echo " A gamma/delta" >> $testroot/stdout.expected
764 cmp -s $testroot/stdout.expected $testroot/stdout
765 ret=$?
766 if [ $ret -ne 0 ]; then
767 diff -u $testroot/stdout.expected $testroot/stdout
768 fi
769 test_done "$testroot" "$ret"
772 test_log_merge_commit_nonexistent_path() {
773 local testroot=`test_init log_merge_commit_corner_case 1`
775 # Create the following commit graph (most recent commit shown first):
777 # o create dir/beta
778 # |
779 # o merge (does not touch dir)
780 # / \
781 # o o changes which don't touch the directory "dir"
782 # \ /
783 # o initial commit, which includes directory "dir" but not dir/beta
786 mkdir $testroot/repo/dir
787 touch $testroot/repo/dir/alpha
788 git -C $testroot/repo add dir/alpha
789 git_commit $testroot/repo -m "initial commit"
791 git -C $testroot/repo checkout -q -b aux
792 touch $testroot/repo/gamma
793 git -C $testroot/repo add gamma
794 git_commit $testroot/repo -m "change on aux"
796 git -C $testroot/repo checkout -q master
797 touch $testroot/repo/delta
798 git -C $testroot/repo add delta
799 git_commit $testroot/repo -m "change on master"
801 git -C $testroot/repo merge -q -m "merge" aux
803 touch $testroot/repo/dir/beta
804 git -C $testroot/repo add dir/beta
805 git_commit $testroot/repo -m "add beta"
807 head_commit=`git_show_head $testroot/repo`
809 got log -r $testroot/repo -b dir/beta | grep ^commit > $testroot/stdout
810 ret=$?
811 if [ $ret -ne 0 ]; then
812 echo "log command failed unexpectedly" >&2
813 test_done "$testroot" "1"
814 return 1
815 fi
817 echo "commit $head_commit (master)" > $testroot/stdout.expected
818 cmp -s $testroot/stdout.expected $testroot/stdout
819 ret=$?
820 if [ $ret -ne 0 ]; then
821 diff -u $testroot/stdout.expected $testroot/stdout
822 fi
823 test_done "$testroot" "$ret"
826 test_log_submodule() {
827 local testroot=`test_init log_submodule`
829 make_single_file_repo $testroot/repo2 foo
831 git -C $testroot/repo -c protocol.file.allow=always \
832 submodule -q add ../repo2
833 git -C $testroot/repo commit -q -m 'adding submodule'
834 local head_commit=`git_show_head $testroot/repo`
836 echo "commit $head_commit (master)" > $testroot/stdout.expected
838 got log -r $testroot/repo -l1 repo2 | grep ^commit > $testroot/stdout
839 cmp -s $testroot/stdout.expected $testroot/stdout
840 ret=$?
841 if [ $ret -ne 0 ]; then
842 diff -u $testroot/stdout.expected $testroot/stdout
843 test_done "$testroot" "$ret"
844 return 1
845 fi
847 echo " A .gitmodules" > $testroot/stdout.expected
849 got log -r $testroot/repo -l1 -P repo2 | grep '^ [MDmA]' \
850 > $testroot/stdout
851 cmp -s $testroot/stdout.expected $testroot/stdout
852 ret=$?
853 if [ $ret -ne 0 ]; then
854 diff -u $testroot/stdout.expected $testroot/stdout
855 test_done "$testroot" "$ret"
856 return 1
857 fi
859 got log -p -r $testroot/repo -l1 repo2 \
860 > $testroot/stdout 2> $testroot/stderr
861 ret=$?
862 if [ $ret -eq 0 ]; then
863 echo "log command succeeded unexpectedly" >&2
864 test_done "$testroot" "1"
865 return 1
866 fi
867 local submodule_id=$(got tree -r $testroot/repo -i | \
868 grep 'repo2\$$' | cut -d ' ' -f1)
869 echo "got: object $submodule_id not found" > $testroot/stderr.expected
871 cmp -s $testroot/stderr.expected $testroot/stderr
872 ret=$?
873 if [ $ret -ne 0 ]; then
874 diff -u $testroot/stderr.expected $testroot/stderr
875 test_done "$testroot" "$ret"
876 return 1
877 fi
879 echo "modified foo" > $testroot/repo2/foo
880 git -C $testroot/repo2 commit -q -a -m 'modified a submodule'
882 # Update the repo/repo2 submodule link
883 git -C $testroot/repo/repo2 pull -q
884 git -C $testroot/repo add repo2
885 git_commit $testroot/repo -m "changed submodule link"
887 # log -P does not show the changed submodule path
888 got log -P -r $testroot/repo -l1 repo2 > $testroot/stdout.full
889 ret=$?
890 if [ $ret -ne 0 ]; then
891 echo "log command failed unexpectedly" >&2
892 test_done "$testroot" "1"
893 return 1
894 fi
895 grep '^ [MDmA]' $testroot/stdout.full > $testroot/stdout
897 echo -n > $testroot/stdout.expected
898 cmp -s $testroot/stdout.expected $testroot/stdout
899 ret=$?
900 if [ $ret -ne 0 ]; then
901 diff -u $testroot/stdout.expected $testroot/stdout
902 fi
903 test_done "$testroot" "$ret"
906 test_log_diffstat() {
907 local testroot=`test_init log_diffstat`
909 got checkout $testroot/repo $testroot/wt > /dev/null
910 ret=$?
911 if [ $ret -ne 0 ]; then
912 test_done "$testroot" "$ret"
913 return 1
914 fi
916 printf "modified\nalpha.\n" > $testroot/wt/alpha
917 (cd $testroot/wt && got commit -m 'log_diffstat mod file' > /dev/null)
919 (cd $testroot/wt && got rm beta >/dev/null)
920 (cd $testroot/wt && chmod +x epsilon/zeta >/dev/null)
921 (cd $testroot/wt && got commit -m 'log_diffstat rm file' > /dev/null)
923 echo "new file" > $testroot/wt/new
924 (cd $testroot/wt && got add new >/dev/null)
925 (cd $testroot/wt && got commit -m 'log_diffstat add file' > /dev/null)
927 cat <<EOF >$testroot/stdout.expected
928 A new | 1+ 0-
930 1 file changed, 1 insertion(+), 0 deletions(-)
931 D beta | 0+ 1-
932 m epsilon/zeta | 0+ 0-
934 2 files changed, 0 insertions(+), 1 deletion(-)
935 M alpha | 2+ 1-
937 1 file changed, 2 insertions(+), 1 deletion(-)
938 A alpha | 1+ 0-
939 A beta | 1+ 0-
940 A epsilon/zeta | 1+ 0-
941 A gamma/delta | 1+ 0-
943 4 files changed, 4 insertions(+), 0 deletions(-)
944 EOF
946 # try different -dPp combinations
947 for flags in -d -dP -dp -dPp; do
948 (cd $testroot/wt && got log $flags | grep -A2 '^ [MDmA]' | \
949 sed '/^--/d' > $testroot/stdout)
951 cmp -s $testroot/stdout.expected $testroot/stdout
952 ret=$?
953 if [ $ret -ne 0 ]; then
954 diff -u $testroot/stdout.expected $testroot/stdout
955 test_done "$testroot" "$ret"
956 return 1
957 fi
958 done
960 test_done "$testroot" "0"
963 test_log_commit_keywords() {
964 local testroot=$(test_init log_commit_keywords)
965 local commit_time=`git_show_author_time $testroot/repo`
966 local d=`date -u -r $commit_time +"%G-%m-%d"`
968 set -- "$(git_show_head $testroot/repo)"
970 got checkout $testroot/repo $testroot/wt > /dev/null
971 ret=$?
972 if [ $ret -ne 0 ]; then
973 echo "checkout failed unexpectedly" >&2
974 test_done "$testroot" "$ret"
975 return 1
976 fi
978 for i in $(seq 16); do
979 echo "alpha change $i" > "$testroot/wt/alpha"
981 (cd "$testroot/wt" && got ci -m "commit number $i" > /dev/null)
982 ret=$?
983 if [ $ret -ne 0 ]; then
984 echo "commit failed unexpectedly" >&2
985 test_done "$testroot" "$ret"
986 return 1
987 fi
988 set -- "$@" "$(git_show_head $testroot/repo)"
989 done
991 for i in $(seq 16 2); do
992 printf '%s %.7s commit number %s\n' \
993 "$d" $(pop_idx $i $@) "$(( i-1 ))" \
994 >> $testroot/stdout.expected
995 done
997 got log -r "$testroot/repo" -s -cmaster:- -l15 > $testroot/stdout
999 cmp -s $testroot/stdout.expected $testroot/stdout
1000 ret=$?
1001 if [ $ret -ne 0 ]; then
1002 diff -u $testroot/stdout.expected $testroot/stdout
1003 test_done "$testroot" "$ret"
1004 return 1
1007 # request same set of commits now with log -x
1008 got log -r "$testroot/repo" -s -cmaster:- -xmaster:-15 > \
1009 $testroot/stdout
1011 cmp -s $testroot/stdout.expected $testroot/stdout
1012 ret=$?
1013 if [ $ret -ne 0 ]; then
1014 diff -u $testroot/stdout.expected $testroot/stdout
1015 test_done "$testroot" "$ret"
1016 return 1
1019 (cd $testroot/wt && got update -c:head:-8 > /dev/null)
1020 ret=$?
1021 if [ $ret -ne 0 ]; then
1022 echo "update failed unexpectedly" >&2
1023 test_done "$testroot" "1"
1024 return 1
1027 echo -n > "$testroot/stdout.expected"
1029 for i in $(seq 9 2); do
1030 printf '%s %.7s commit number %s\n' \
1031 "$d" $(pop_idx $i $@) "$(( i-1 ))" \
1032 >> $testroot/stdout.expected
1033 done
1034 printf '%s %.7s adding the test tree\n' "$d" $(pop_idx 1 $@) >> \
1035 $testroot/stdout.expected
1037 (cd $testroot/wt && got log -s -c:base > $testroot/stdout)
1039 cmp -s $testroot/stdout.expected $testroot/stdout
1040 ret=$?
1041 if [ $ret -ne 0 ]; then
1042 diff -u $testroot/stdout.expected $testroot/stdout
1043 test_done "$testroot" "$ret"
1044 return 1
1047 # from head to the base commit using -x
1048 printf '%s %-7s commit number 16\n' "$d" "master" > \
1049 $testroot/stdout.expected
1050 for i in $(seq 16 9); do
1051 printf '%s %.7s commit number %s\n' \
1052 "$d" $(pop_idx $i $@) $(( i-1 )) \
1053 >> $testroot/stdout.expected
1054 done
1056 (cd $testroot/wt && got log -s -c:head -x:base > $testroot/stdout)
1058 cmp -s $testroot/stdout.expected $testroot/stdout
1059 ret=$?
1060 if [ $ret -ne 0 ]; then
1061 diff -u $testroot/stdout.expected $testroot/stdout
1062 test_done "$testroot" "$ret"
1063 return 1
1066 # if + modifier is too great, use HEAD commit
1067 printf '%s %-7s commit number %s\n' "$d" master 16 > \
1068 $testroot/stdout.expected
1069 printf '%s %.7s commit number %s\n' "$d" $(pop_idx 16 $@) 15 >> \
1070 $testroot/stdout.expected
1072 (cd $testroot/wt && got log -s -c:base:+20 -l2 > $testroot/stdout)
1074 cmp -s $testroot/stdout.expected $testroot/stdout
1075 ret=$?
1076 if [ $ret -ne 0 ]; then
1077 diff -u $testroot/stdout.expected $testroot/stdout
1078 test_done "$testroot" "$ret"
1079 return 1
1082 # if - modifier is too great, use root commit
1083 printf '%s %.7s adding the test tree\n' "$d" $(pop_idx 1 $@) > \
1084 $testroot/stdout.expected
1086 (cd $testroot/wt && got log -s -c:base:-10 > $testroot/stdout)
1087 cmp -s $testroot/stdout.expected $testroot/stdout
1088 ret=$?
1089 if [ $ret -ne 0 ]; then
1090 diff -u $testroot/stdout.expected $testroot/stdout
1091 test_done "$testroot" "$ret"
1092 return 1
1095 got br -r "$testroot/repo" -c $(pop_idx 1 $@) base+
1097 printf '%s %.7s commit number 1\n' "$d" $(pop_idx 2 $@) > \
1098 $testroot/stdout.expected
1100 (cd $testroot/wt && got log -s -cbase+:+ -l1 > $testroot/stdout)
1102 cmp -s $testroot/stdout.expected $testroot/stdout
1103 ret=$?
1104 if [ $ret -ne 0 ]; then
1105 diff -u $testroot/stdout.expected $testroot/stdout
1106 test_done "$testroot" "$ret"
1107 return 1
1110 got br -r "$testroot/repo" -c $(pop_idx 3 $@) head-1
1112 printf '%s %.7s commit number 1\n' "$d" $(pop_idx 2 $@) > \
1113 $testroot/stdout.expected
1115 (cd $testroot/wt && got log -s -chead-1:- -l1 > $testroot/stdout)
1117 cmp -s $testroot/stdout.expected $testroot/stdout
1118 ret=$?
1119 if [ $ret -ne 0 ]; then
1120 diff -u $testroot/stdout.expected $testroot/stdout
1121 test_done "$testroot" "$ret"
1122 return 1
1125 got br -r "$testroot/repo" -c $(pop_idx 16 $@) base-1+2
1127 printf '%s %.7s commit number 12\n' "$d" $(pop_idx 13 $@) > \
1128 $testroot/stdout.expected
1130 (cd $testroot/wt && got log -s -cbase-1+2:-3 -l1 > $testroot/stdout)
1132 cmp -s $testroot/stdout.expected $testroot/stdout
1133 ret=$?
1134 if [ $ret -ne 0 ]; then
1135 diff -u $testroot/stdout.expected $testroot/stdout
1136 test_done "$testroot" "$ret"
1137 return 1
1140 echo "got: '::base:+': invalid commit keyword" > \
1141 $testroot/stderr.expected
1143 (cd $testroot/wt && got log -c::base:+ 2> $testroot/stderr)
1145 cmp -s $testroot/stderr.expected $testroot/stderr
1146 ret=$?
1147 if [ $ret -ne 0 ]; then
1148 diff -u $testroot/stderr.expected $testroot/stderr
1149 test_done "$testroot" "$ret"
1150 return 1
1153 echo "got: ':head:-:': invalid commit keyword" > \
1154 $testroot/stderr.expected
1156 (cd $testroot/wt && got log -c:head:-: 2> $testroot/stderr)
1158 cmp -s $testroot/stderr.expected $testroot/stderr
1159 ret=$?
1160 if [ $ret -ne 0 ]; then
1161 diff -u $testroot/stderr.expected $testroot/stderr
1162 test_done "$testroot" "$ret"
1163 return 1
1166 echo "got: 'master::+': invalid commit keyword" > \
1167 $testroot/stderr.expected
1169 (cd $testroot/wt && got log -cmaster::+ 2> $testroot/stderr)
1171 cmp -s $testroot/stderr.expected $testroot/stderr
1172 ret=$?
1173 if [ $ret -ne 0 ]; then
1174 diff -u $testroot/stderr.expected $testroot/stderr
1175 test_done "$testroot" "$ret"
1176 return 1
1179 echo "got: 'master:1+': invalid commit keyword" > \
1180 $testroot/stderr.expected
1182 (cd $testroot/wt && got log -cmaster:1+ 2> $testroot/stderr)
1184 cmp -s $testroot/stderr.expected $testroot/stderr
1185 ret=$?
1186 if [ $ret -ne 0 ]; then
1187 diff -u $testroot/stderr.expected $testroot/stderr
1188 test_done "$testroot" "$ret"
1189 return 1
1192 echo "got: ':base:-1:base:-1': invalid commit keyword" > \
1193 $testroot/stderr.expected
1195 (cd $testroot/wt && got log -c:base:-1:base:-1 2> $testroot/stderr)
1197 cmp -s $testroot/stderr.expected $testroot/stderr
1198 ret=$?
1199 if [ $ret -ne 0 ]; then
1200 diff -u $testroot/stderr.expected $testroot/stderr
1201 test_done "$testroot" "$ret"
1202 return 1
1205 echo "got: 'main:-main:-': invalid commit keyword" > \
1206 $testroot/stderr.expected
1208 (cd $testroot/wt && got log -cmain:-main:- 2> $testroot/stderr)
1210 cmp -s $testroot/stderr.expected $testroot/stderr
1211 ret=$?
1212 if [ $ret -ne 0 ]; then
1213 diff -u $testroot/stderr.expected $testroot/stderr
1214 test_done "$testroot" "$ret"
1215 return 1
1218 echo "got: ':base:*1': invalid commit keyword" > \
1219 $testroot/stderr.expected
1221 (cd $testroot/wt && got log -c:base:*1 2> $testroot/stderr)
1223 cmp -s $testroot/stderr.expected $testroot/stderr
1224 ret=$?
1225 if [ $ret -ne 0 ]; then
1226 diff -u $testroot/stderr.expected $testroot/stderr
1227 test_done "$testroot" "$ret"
1228 return 1
1231 echo "got: reference null not found" > $testroot/stderr.expected
1233 (cd $testroot/wt && got log -cnull:+ 2> $testroot/stderr)
1235 cmp -s $testroot/stderr.expected $testroot/stderr
1236 ret=$?
1237 if [ $ret -ne 0 ]; then
1238 diff -u $testroot/stderr.expected $testroot/stderr
1241 test_done "$testroot" "$ret"
1244 test_log_toposort() {
1245 local testroot=`test_init log_toposort`
1246 local commit0=`git_show_head $testroot/repo`
1247 local author_time0=`git_show_author_time $testroot/repo`
1249 got checkout $testroot/repo $testroot/wt > /dev/null
1250 ret=$?
1251 if [ $ret -ne 0 ]; then
1252 test_done "$testroot" "$ret"
1253 return 1
1256 echo aaa > $testroot/wt/alpha
1257 (cd $testroot/wt && got commit -m 'change alpha' >/dev/null)
1258 local commit1=`git_show_head $testroot/repo`
1259 local author_time1=`git_show_author_time $testroot/repo`
1261 got branch -r $testroot/repo -c $commit0 newbranch
1262 (cd $testroot/wt && got update -b newbranch > /dev/null)
1263 echo ddd > $testroot/wt/gamma/delta
1264 (cd $testroot/wt && got commit -m 'change delta' >/dev/null)
1265 local commit2=`git_show_branch_head $testroot/repo newbranch`
1266 local author_time2=`git_show_author_time $testroot/repo newbranch`
1268 echo zzz > $testroot/wt/epsilon/zeta
1269 (cd $testroot/wt && got commit -m 'change zeta' >/dev/null)
1270 local commit3=`git_show_head $testroot/repo`
1271 local author_time3=`git_show_author_time $testroot/repo newbranch`
1273 (cd $testroot/wt && got update -b master > /dev/null)
1274 (cd $testroot/wt && got merge newbranch > /dev/null)
1275 local merge_commit=`git_show_head $testroot/repo`
1276 local merge_time=`git_show_author_time $testroot/repo`
1278 local short_commit0=`trim_obj_id 33 $commit0`
1279 local short_commit1=`trim_obj_id 33 $commit1`
1280 local short_commit2=`trim_obj_id 33 $commit2`
1281 local short_commit3=`trim_obj_id 33 $commit3`
1283 d_0=`date -u -r $author_time0 +"%G-%m-%d"`
1284 d_1=`date -u -r $author_time1 +"%G-%m-%d"`
1285 d_2=`date -u -r $author_time2 +"%G-%m-%d"`
1286 d_3=`date -u -r $author_time3 +"%G-%m-%d"`
1287 d_m=`date -u -r $merge_time +"%G-%m-%d"`
1289 got log -r $testroot/repo -s -b -t > $testroot/stdout
1290 cat > $testroot/stdout.expected <<EOF
1291 $d_m master merge refs/heads/newbranch into refs/heads/master
1292 $d_1 $short_commit1 change alpha
1293 $d_3 newbranch change zeta
1294 $d_2 $short_commit2 change delta
1295 $d_0 $short_commit0 adding the test tree
1296 EOF
1297 cmp -s $testroot/stdout.expected $testroot/stdout
1298 ret=$?
1299 if [ $ret -ne 0 ]; then
1300 diff -u $testroot/stdout.expected $testroot/stdout
1302 test_done "$testroot" "$ret"
1306 test_parseargs "$@"
1307 run_test test_log_in_repo
1308 run_test test_log_in_bare_repo
1309 run_test test_log_in_worktree
1310 run_test test_log_in_worktree_with_path_prefix
1311 run_test test_log_tag
1312 run_test test_log_limit
1313 run_test test_log_oneline
1314 run_test test_log_patch_added_file
1315 run_test test_log_nonexistent_path
1316 run_test test_log_end_at_commit
1317 run_test test_log_reverse_display
1318 run_test test_log_in_worktree_different_repo
1319 run_test test_log_changed_paths
1320 run_test test_log_merge_commit_nonexistent_path
1321 run_test test_log_submodule
1322 run_test test_log_diffstat
1323 run_test test_log_commit_keywords
1324 run_test test_log_toposort