#!/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 'generate foo/log' 'cgit_url "foo/log" >tmp' test_expect_success 'find commit 1' 'grep "commit 1" tmp' test_expect_success 'find commit 5' 'grep "commit 5" tmp' test_expect_success 'generate bar/log' 'cgit_url "bar/log" >tmp' test_expect_success 'find commit 1' 'grep "commit 1" tmp' test_expect_success 'find commit 50' 'grep "commit 50" tmp' # The switch button submits the select as h, so whatever head the request # follows has to sit in the list selected, or submitting would quietly move # the visitor to the first branch. test_expect_success 'a detached head stays selected in the switcher' ' sha=$(git -C repos/foo rev-parse master~1) && cgit_url "foo/log&h=$sha" >tmp && grep "option value=.$sha. selected" tmp ' test_expect_success 'a tag head stays selected in the switcher' ' git -C repos/foo tag t-switch master~1 && cgit_url "foo/log&h=t-switch" >tmp && grep "option value=.t-switch. selected>t-switch (detached)" tmp && git -C repos/foo tag -d t-switch ' test_expect_success 'a branch head keeps its plain option' ' cgit_url "foo/log&h=master" >tmp && grep "option value=.master. selected>master<" tmp && ! grep "detached" tmp ' test_expect_success 'generate "with%20space/log?qt=grep&q=commit+1"' ' cgit_url "with+space/log&qt=grep&q=commit+1" >tmp ' test_expect_success 'find commit 1' 'grep "commit 1" tmp' test_expect_success 'find link with %20 in path' 'grep "/with%20space/log/?qt=grep" tmp' test_expect_success 'find link with + in arg' 'grep "/log/?qt=grep&q=commit+1" tmp' test_expect_success 'no links with space in path' '! grep "href=./with space/" tmp' test_expect_success 'no links with space in arg' '! grep "q=commit 1" tmp' test_expect_success 'commit 2 is not visible' '! grep "commit 2" tmp' test_done