#!/bin/sh # The log page and its search. The searching checks use the repository whose # name contains a space and a term containing a space, so every link cgit # writes back has to escape the path and the query, which escape differently. test_description='Check content on log page' . ./setup.sh test_expect_success 'the log lists the whole of a short history' ' cgit_ok_url "foo/log" >tmp && test_grep ">commit 1<" tmp && test_grep ">commit 5<" tmp ' test_expect_success 'the first log page holds fifty commits' ' cgit_ok_url "bar/log" >tmp && test_grep ">commit 1<" tmp && test_grep ">commit 50<" tmp ' test_expect_success 'the log counts the files and lines a commit changed' ' test_create_repo repos/counts && ( cd repos/counts && printf "1\n2\n3\n" >a.txt && git add a.txt && git commit -m "add a" && printf "1\n3\n4\n5\n" >a.txt && echo x >b.txt && git add a.txt b.txt && git commit -m "change both" ) && cgitrc_repo countsrc counts enable-log-filecount=1 enable-log-linecount=1 && cgit_ok countsrc "url=counts/log/" >tmp && 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 "/