3 # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
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.
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.
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
30 if [ $ret -ne 0 ]; then
31 diff -u $testroot/stdout.expected
$testroot/stdout
32 test_done
"$testroot" "$ret"
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
42 if [ $ret -ne 0 ]; then
43 diff -u $testroot/stdout.expected
$testroot/stdout
44 test_done
"$testroot" "$ret"
49 test_done
"$testroot" "0"
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
63 if [ $ret -ne 0 ]; then
64 diff -u $testroot/stdout.expected
$testroot/stdout
65 test_done
"$testroot" "$ret"
70 test_done
"$testroot" "0"
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
85 if [ $ret -ne 0 ]; then
86 test_done
"$testroot" "$ret"
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
97 if [ $ret -ne 0 ]; then
98 diff -u $testroot/stdout.expected
$testroot/stdout
99 test_done
"$testroot" "$ret"
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
109 if [ $ret -ne 0 ]; then
110 diff -u $testroot/stdout.expected
$testroot/stdout
111 test_done
"$testroot" "$ret"
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
121 if [ $ret -ne 0 ]; then
122 diff -u $testroot/stdout.expected
$testroot/stdout
123 test_done
"$testroot" "$ret"
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
145 if [ $ret -ne 0 ]; then
146 test_done
"$testroot" "$ret"
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
157 if [ $ret -ne 0 ]; then
158 diff -u $testroot/stdout.expected
$testroot/stdout
159 test_done
"$testroot" "$ret"
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
171 if [ $ret -ne 0 ]; then
172 diff -u $testroot/stdout.expected
$testroot/stdout
173 test_done
"$testroot" "$ret"
178 test_done
"$testroot" "0"
182 local testroot
=`test_init log_tag`
183 local commit_id
=`git_show_head $testroot/repo`
187 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
189 if [ $ret -ne 0 ]; then
190 test_done
"$testroot" "$ret"
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 \
199 cmp -s $testroot/stdout.expected
$testroot/stdout
201 if [ $ret -ne 0 ]; then
202 diff -u $testroot/stdout.expected
$testroot/stdout
203 test_done
"$testroot" "$ret"
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 \
214 cmp -s $testroot/stdout.expected
$testroot/stdout
216 if [ $ret -ne 0 ]; then
217 diff -u $testroot/stdout.expected
$testroot/stdout
219 test_done
"$testroot" "$ret"
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
228 if [ $ret -ne 0 ]; then
229 test_done
"$testroot" "$ret"
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
251 if [ $ret -ne 0 ]; then
252 diff -u $testroot/stdout.expected
$testroot/stdout
253 test_done
"$testroot" "$ret"
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
264 if [ $ret -ne 0 ]; then
265 diff -u $testroot/stdout.expected
$testroot/stdout
266 test_done
"$testroot" "$ret"
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
279 if [ $ret -ne 0 ]; then
280 diff -u $testroot/stdout.expected
$testroot/stdout
281 test_done
"$testroot" "$ret"
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
294 if [ $ret -ne 0 ]; then
295 diff -u $testroot/stdout.expected
$testroot/stdout
297 test_done
"$testroot" "0"
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
305 if [ $ret -ne 0 ]; then
306 test_done
"$testroot" "$ret"
310 echo "modified alpha" > $testroot/wt
/alpha
311 (cd $testroot/wt
&& got commit
-m "test oneline
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
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 +"%F"`
323 printf "$d %-7s test oneline\n" master
> $testroot/stdout.expected
324 d
=`date -u -r $author_time2 +"%F"`
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
330 if [ $ret -ne 0 ]; then
331 diff -u $testroot/stdout.expected
$testroot/stdout
332 test_done
"$testroot" "$ret"
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
344 if [ $ret -ne 0 ]; then
345 test_done
"$testroot" "$ret"
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)
360 if [ $ret -ne 0 ]; then
361 echo "got log command failed unexpectedly" >&2
362 test_done
"$testroot" "$ret"
365 grep ^commit
$testroot/stdout.
patch > $testroot/stdout
366 cmp -s $testroot/stdout.expected
$testroot/stdout
368 if [ $ret -ne 0 ]; then
369 diff -u $testroot/stdout.expected
$testroot/stdout
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
)
383 if [ $ret -eq 0 ]; then
384 echo "log command succeeded unexpectedly" >&2
385 test_done
"$testroot" "1"
389 echo -n > $testroot/stdout.expected
390 cmp -s $testroot/stdout.expected
$testroot/stdout
392 if [ $ret -ne 0 ]; then
393 diff -u $testroot/stdout.expected
$testroot/stdout
394 test_done
"$testroot" "$ret"
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
402 if [ $ret -ne 0 ]; then
403 diff -u $testroot/stderr.expected
$testroot/stderr
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
414 if [ $ret -ne 0 ]; then
415 test_done
"$testroot" "$ret"
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 \
436 cmp -s $testroot/stdout.expected
$testroot/stdout
438 if [ $ret -ne 0 ]; then
439 diff -u $testroot/stdout.expected
$testroot/stdout
440 test_done
"$testroot" "$ret"
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
452 if [ $ret -ne 0 ]; then
453 diff -u $testroot/stdout.expected
$testroot/stdout
454 test_done
"$testroot" "$ret"
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 \
468 cmp -s $testroot/stdout.expected
$testroot/stdout
470 if [ $ret -ne 0 ]; then
471 diff -u $testroot/stdout.expected
$testroot/stdout
472 test_done
"$testroot" "$ret"
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 \
480 cmp -s $testroot/stdout.expected
$testroot/stdout
482 if [ $ret -ne 0 ]; then
483 diff -u $testroot/stdout.expected
$testroot/stdout
484 test_done
"$testroot" "$ret"
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 \
496 cmp -s $testroot/stdout.expected
$testroot/stdout
498 if [ $ret -ne 0 ]; then
499 diff -u $testroot/stdout.expected
$testroot/stdout
500 test_done
"$testroot" "$ret"
504 # got will refuse -x with a non-existent commit
505 (cd $testroot/wt
&& got log
-x nonexistent \
506 > $testroot/stdout
2> $testroot/stderr
)
508 if [ $ret -eq 0 ]; then
509 echo "log command succeeded unexpectedly" >&2
510 test_done
"$testroot" "1"
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
518 if [ $ret -ne 0 ]; then
519 diff -u $testroot/stderr.expected
$testroot/stderr
520 test_done
"$testroot" "$ret"
523 cmp -s $testroot/stdout.expected
$testroot/stdout
525 if [ $ret -ne 0 ]; then
526 diff -u $testroot/stdout.expected
$testroot/stdout
527 test_done
"$testroot" "$ret"
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
)
537 if [ $ret -eq 0 ]; then
538 echo "log command succeeded unexpectedly" >&2
539 test_done
"$testroot" "1"
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
547 if [ $ret -ne 0 ]; then
548 diff -u $testroot/stderr.expected
$testroot/stderr
549 test_done
"$testroot" "$ret"
552 cmp -s $testroot/stdout.expected
$testroot/stdout
554 if [ $ret -ne 0 ]; then
555 diff -u $testroot/stdout.expected
$testroot/stdout
556 test_done
"$testroot" "$ret"
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
569 if [ $ret -ne 0 ]; then
570 test_done
"$testroot" "$ret"
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
595 if [ $ret -ne 0 ]; then
596 diff -u $testroot/stdout.expected
$testroot/stdout
597 test_done
"$testroot" "$ret"
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
607 if [ $ret -ne 0 ]; then
608 diff -u $testroot/stdout.expected
$testroot/stdout
609 test_done
"$testroot" "$ret"
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
621 if [ $ret -ne 0 ]; then
622 diff -u $testroot/stdout.expected
$testroot/stdout
623 test_done
"$testroot" "$ret"
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
634 if [ $ret -ne 0 ]; then
635 diff -u $testroot/stdout.expected
$testroot/stdout
636 test_done
"$testroot" "$ret"
640 # -R works in combination with -P
641 echo "" > $testroot/stdout.expected
642 (cd $testroot/wt
&& got log
-R -P |
grep -E '^(commit| [MDmA])' \
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
657 if [ $ret -ne 0 ]; then
658 diff -u $testroot/stdout.expected
$testroot/stdout
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 got 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
679 if [ $ret -ne 0 ]; then
680 test_done
"$testroot" "$ret"
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
694 if [ $ret -ne 0 ]; then
695 diff -u $testroot/stdout.expected
$testroot/stdout
696 test_done
"$testroot" "$ret"
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
706 if [ $ret -ne 0 ]; then
707 diff -u $testroot/stdout.expected
$testroot/stdout
708 test_done
"$testroot" "$ret"
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
718 if [ $ret -ne 0 ]; then
719 diff -u $testroot/stdout.expected
$testroot/stdout
720 test_done
"$testroot" "$ret"
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
734 if [ $ret -ne 0 ]; then
735 test_done
"$testroot" "$ret"
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
766 if [ $ret -ne 0 ]; then
767 diff -u $testroot/stdout.expected
$testroot/stdout
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):
779 # o merge (does not touch dir)
781 # o o changes which don't touch the directory "dir"
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
811 if [ $ret -ne 0 ]; then
812 echo "log command failed unexpectedly" >&2
813 test_done
"$testroot" "1"
817 echo "commit $head_commit (master)" > $testroot/stdout.expected
818 cmp -s $testroot/stdout.expected
$testroot/stdout
820 if [ $ret -ne 0 ]; then
821 diff -u $testroot/stdout.expected
$testroot/stdout
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
841 if [ $ret -ne 0 ]; then
842 diff -u $testroot/stdout.expected
$testroot/stdout
843 test_done
"$testroot" "$ret"
847 echo " A .gitmodules" > $testroot/stdout.expected
849 got log
-r $testroot/repo
-l1 -P repo2 |
grep '^ [MDmA]' \
851 cmp -s $testroot/stdout.expected
$testroot/stdout
853 if [ $ret -ne 0 ]; then
854 diff -u $testroot/stdout.expected
$testroot/stdout
855 test_done
"$testroot" "$ret"
859 got log
-p -r $testroot/repo
-l1 repo2 \
860 > $testroot/stdout
2> $testroot/stderr
862 if [ $ret -eq 0 ]; then
863 echo "log command succeeded unexpectedly" >&2
864 test_done
"$testroot" "1"
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
873 if [ $ret -ne 0 ]; then
874 diff -u $testroot/stderr.expected
$testroot/stderr
875 test_done
"$testroot" "$ret"
879 echo "modified foo" > $testroot/repo
2/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
890 if [ $ret -ne 0 ]; then
891 echo "log command failed unexpectedly" >&2
892 test_done
"$testroot" "1"
895 grep '^ [MDmA]' $testroot/stdout.full
> $testroot/stdout
897 echo -n > $testroot/stdout.expected
898 cmp -s $testroot/stdout.expected
$testroot/stdout
900 if [ $ret -ne 0 ]; then
901 diff -u $testroot/stdout.expected
$testroot/stdout
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
911 if [ $ret -ne 0 ]; then
912 test_done
"$testroot" "$ret"
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
930 1 file changed, 1 insertion(+), 0 deletions(-)
932 m epsilon/zeta | 0+ 0-
934 2 files changed, 0 insertions(+), 1 deletion(-)
937 1 file changed, 2 insertions(+), 1 deletion(-)
940 A epsilon/zeta | 1+ 0-
941 A gamma/delta | 1+ 0-
943 4 files changed, 4 insertions(+), 0 deletions(-)
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
953 if [ $ret -ne 0 ]; then
954 diff -u $testroot/stdout.expected
$testroot/stdout
955 test_done
"$testroot" "$ret"
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 +"%F"`
968 set -- "$(git_show_head $testroot/repo)"
970 got checkout
$testroot/repo
$testroot/wt
> /dev
/null
972 if [ $ret -ne 0 ]; then
973 echo "checkout failed unexpectedly" >&2
974 test_done
"$testroot" "$ret"
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
)
983 if [ $ret -ne 0 ]; then
984 echo "commit failed unexpectedly" >&2
985 test_done
"$testroot" "$ret"
988 set -- "$@" "$(git_show_head $testroot/repo)"
991 for i
in $
(seq 16 -1 2); do
992 printf '%s %.7s commit number %s\n' \
993 "$d" $
(pop_idx
$i $@
) "$(( i-1 ))" \
994 >> $testroot/stdout.expected
997 got log
-r "$testroot/repo" -s -cmaster:- -l15 > $testroot/stdout
999 cmp -s $testroot/stdout.expected
$testroot/stdout
1001 if [ $ret -ne 0 ]; then
1002 diff -u $testroot/stdout.expected
$testroot/stdout
1003 test_done
"$testroot" "$ret"
1007 # request same set of commits now with log -x
1008 got log
-r "$testroot/repo" -s -cmaster:- -xmaster:-15 > \
1011 cmp -s $testroot/stdout.expected
$testroot/stdout
1013 if [ $ret -ne 0 ]; then
1014 diff -u $testroot/stdout.expected
$testroot/stdout
1015 test_done
"$testroot" "$ret"
1019 (cd $testroot/wt
&& got update
-c:head:-8 > /dev
/null
)
1021 if [ $ret -ne 0 ]; then
1022 echo "update failed unexpectedly" >&2
1023 test_done
"$testroot" "1"
1027 echo -n > "$testroot/stdout.expected"
1029 for i
in $
(seq 9 -1 2); do
1030 printf '%s %.7s commit number %s\n' \
1031 "$d" $
(pop_idx
$i $@
) "$(( i-1 ))" \
1032 >> $testroot/stdout.expected
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
1041 if [ $ret -ne 0 ]; then
1042 diff -u $testroot/stdout.expected
$testroot/stdout
1043 test_done
"$testroot" "$ret"
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 -1 9); do
1051 printf '%s %.7s commit number %s\n' \
1052 "$d" $
(pop_idx
$i $@
) $
(( i-1
)) \
1053 >> $testroot/stdout.expected
1056 (cd $testroot/wt
&& got log
-s -c:head -x:base
> $testroot/stdout
)
1058 cmp -s $testroot/stdout.expected
$testroot/stdout
1060 if [ $ret -ne 0 ]; then
1061 diff -u $testroot/stdout.expected
$testroot/stdout
1062 test_done
"$testroot" "$ret"
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
1076 if [ $ret -ne 0 ]; then
1077 diff -u $testroot/stdout.expected
$testroot/stdout
1078 test_done
"$testroot" "$ret"
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
1089 if [ $ret -ne 0 ]; then
1090 diff -u $testroot/stdout.expected
$testroot/stdout
1091 test_done
"$testroot" "$ret"
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
1104 if [ $ret -ne 0 ]; then
1105 diff -u $testroot/stdout.expected
$testroot/stdout
1106 test_done
"$testroot" "$ret"
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
1119 if [ $ret -ne 0 ]; then
1120 diff -u $testroot/stdout.expected
$testroot/stdout
1121 test_done
"$testroot" "$ret"
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
1134 if [ $ret -ne 0 ]; then
1135 diff -u $testroot/stdout.expected
$testroot/stdout
1136 test_done
"$testroot" "$ret"
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
1147 if [ $ret -ne 0 ]; then
1148 diff -u $testroot/stderr.expected
$testroot/stderr
1149 test_done
"$testroot" "$ret"
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
1160 if [ $ret -ne 0 ]; then
1161 diff -u $testroot/stderr.expected
$testroot/stderr
1162 test_done
"$testroot" "$ret"
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
1173 if [ $ret -ne 0 ]; then
1174 diff -u $testroot/stderr.expected
$testroot/stderr
1175 test_done
"$testroot" "$ret"
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
1186 if [ $ret -ne 0 ]; then
1187 diff -u $testroot/stderr.expected
$testroot/stderr
1188 test_done
"$testroot" "$ret"
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
1199 if [ $ret -ne 0 ]; then
1200 diff -u $testroot/stderr.expected
$testroot/stderr
1201 test_done
"$testroot" "$ret"
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
1212 if [ $ret -ne 0 ]; then
1213 diff -u $testroot/stderr.expected
$testroot/stderr
1214 test_done
"$testroot" "$ret"
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
1225 if [ $ret -ne 0 ]; then
1226 diff -u $testroot/stderr.expected
$testroot/stderr
1227 test_done
"$testroot" "$ret"
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
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
1251 if [ $ret -ne 0 ]; then
1252 test_done
"$testroot" "$ret"
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 7 $commit0`
1279 local short_commit1
=`trim_obj_id 7 $commit1`
1280 local short_commit2
=`trim_obj_id 7 $commit2`
1281 local short_commit3
=`trim_obj_id 7 $commit3`
1283 d_0
=`date -u -r $author_time0 +"%F"`
1284 d_1
=`date -u -r $author_time1 +"%F"`
1285 d_2
=`date -u -r $author_time2 +"%F"`
1286 d_3
=`date -u -r $author_time3 +"%F"`
1287 d_m
=`date -u -r $merge_time +"%F"`
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
1297 cmp -s $testroot/stdout.expected
$testroot/stdout
1299 if [ $ret -ne 0 ]; then
1300 diff -u $testroot/stdout.expected
$testroot/stdout
1302 test_done
"$testroot" "$ret"
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