From 071ea511ba97be1d60bcb1ed745422989cce9ff7 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 11:56:01 -1000 Subject: 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. --- tests/t0103-log.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests/t0103-log.sh') 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.*2-1/+3" 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 ../../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-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 "/