#!/bin/sh # The tree page. The checks against foo+bar cover a file name and a branch # name that both contain a plus, which cgit percent-encodes in a path as # well as in a query, since a bare plus in a served path reads back as a # space through a query string. test_description='Check content on tree page' . ./setup.sh test_expect_success 'generate bar/tree' 'cgit_url "bar/tree" >tmp' test_expect_success 'find file-1' 'grep "file-1" tmp' test_expect_success 'find file-50' 'grep "file-50" tmp' test_expect_success 'generate bar/tree/file-50' 'cgit_url "bar/tree/file-50" >tmp' test_expect_success 'find line 1' ' grep "1" tmp ' test_expect_success 'no line 2' ' ! grep "2" tmp ' test_expect_success 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >tmp' test_expect_success 'verify a+b link' ' grep "/foo%2Bbar/tree/a%2Bb" tmp ' test_expect_success 'generate foo+bar/tree?h=1+2' 'cgit_url "foo%2bbar/tree&h=1%2b2" >tmp' test_expect_success 'verify a+b?h=1+2 link' ' grep "/foo%2Bbar/tree/a%2Bb?h=1%2B2" tmp ' test_expect_success 'set up a repo with a nested submodule' ' mkrepo repos/submodules 1 && ( cd repos/submodules && sub=$(git rev-parse HEAD) && git update-index --add --cacheinfo 160000,$sub,vendor/sub && git commit -m gitlink ) && { echo "virtual-root=/" && echo "cache-size=0" && echo "enable-blame=1" && echo "repo.url=submodules" && echo "repo.path=$PWD/repos/submodules/.git" } >submodrc ' test_expect_success 'generate submodules/tree/vendor' ' CGIT_CONFIG="$PWD/submodrc" QUERY_STRING="url=submodules/tree/vendor" cgit >tmp ' test_expect_success 'a submodule row shows the entry name alone' ' grep "class=.ls-mod.>sub" tmp && ! grep ">vendor/sub" tmp ' test_expect_success 'the submodule hash is titled with the full id' ' sub=$(git -C repos/submodules rev-parse HEAD~1) && grep "class=.ls-mod-hash. title=.$sub.>" tmp ' test_expect_success 'a submodule row shows no size' ' grep "ls-mod" tmp >row && grep "class=.ls-size.>-" row ' test_expect_success 'a submodule row offers log but not blame or plain' ' grep "ls-mod" tmp >row && grep ">log" row && ! grep ">blame" row && ! grep ">plain" row ' test_expect_success 'a file row still offers blame' ' CGIT_CONFIG="$PWD/submodrc" QUERY_STRING="url=submodules/tree/" cgit >tmp && grep ">blame" tmp ' test_done