Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Test the log orders commit-sort selects
commit-sort had no test anywhere. The history here is one where the
plain walk, date order and topo order all differ, which the test
checks first so a fixture that stopped telling them apart would fail
rather than pass.
Diffstat (limited to 'tests/t0103-log.sh')
| -rwxr-xr-x | tests/t0103-log.sh | 41 |
1 file changed, 41 insertions, 0 deletions
diff --git a/tests/t0103-log.sh b/tests/t0103-log.sh index d920737..ca7c188 100755 --- a/tests/t0103-log.sh +++ b/tests/t0103-log.sh @@ -36,6 +36,47 @@ test_expect_success 'the log counts the files and lines a commit changed' ' test_grep ">change both</a>.*<td class=.col-count.>2</td><td class=.col-count.><span class=.deletions.>-1</span>/<span class=.insertions.>+3</span></td>" tmp ' +# The commit dates run against the history, so the plain walk shows x ahead +# of z1, its child, which date order never does, and topo order keeps each +# line of the merge together where date order interleaves them. +test_expect_success 'set up a history the commit orders tell apart' ' + test_create_repo repos/order && + ( + cd repos/order && + tree=$(git mktree </dev/null) && + x=$(GIT_COMMITTER_DATE="1700000030 +0000" git commit-tree -m x $tree) && + y1=$(GIT_COMMITTER_DATE="1700000040 +0000" git commit-tree -m y1 -p $x $tree) && + y2=$(GIT_COMMITTER_DATE="1700000045 +0000" git commit-tree -m y2 -p $y1 $tree) && + z1=$(GIT_COMMITTER_DATE="1700000020 +0000" git commit-tree -m z1 -p $x $tree) && + z2=$(GIT_COMMITTER_DATE="1700000042 +0000" git commit-tree -m z2 -p $z1 $tree) && + m=$(GIT_COMMITTER_DATE="1700000050 +0000" git commit-tree -m m -p $y2 -p $z2 $tree) && + git update-ref refs/heads/master $m && + git log --format=%s >../../order.plain && + git log --date-order --format=%s >../../order.date && + git log --topo-order --format=%s >../../order.topo + ) && + ! cmp -s order.plain order.date && + ! cmp -s order.date order.topo && + ! cmp -s order.plain order.topo && + cgitrc_repo orderrc order && + cgitrc_repo orderdaterc order commit-sort=date && + cgitrc_repo ordertoporc order repo.commit-sort=topo +' + +test_expect_success 'commit-sort orders the log as git log does' ' + for sort in plain date topo + do + case $sort in + plain) rc=orderrc ;; + date) rc=orderdaterc ;; + topo) rc=ordertoporc ;; + esac && + cgit_ok $rc "url=order/log/" >tmp && + sed -n "s/.*<a href=.\/order\/commit\/?id=[0-9a-f]*.>\([a-z0-9]*\)<\/a>.*/\1/p" tmp >actual && + test_cmp order.$sort actual || return 1 + done +' + # Prints the options of the branch switcher that carry selected. selected_options() { sed -n "/<select name=.h./,/<\/select>/p" "$1" | grep " selected" |
