From 084ffb8c6386a35cda5fa24ba95b227c6bc7551b Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 09:30:31 -1000 Subject: Test a repository url nested inside another No test served two repositories where one url holds the other as a prefix, which is the case the longest match in cgit_parse_url is for. --- tests/t0207-scan.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/t0207-scan.sh') diff --git a/tests/t0207-scan.sh b/tests/t0207-scan.sh index 7a919ec..409f30c 100755 --- a/tests/t0207-scan.sh +++ b/tests/t0207-scan.sh @@ -125,4 +125,27 @@ test_expect_success 'a scan reads the gitweb settings of a repository' ' test_grep ! "Some Owner" tmp ' +# A url can name a repository whose own url holds another's as a prefix, so +# the longest one that matches is the repository, and the rest is the page. +test_expect_success 'a nested repository url goes to the deepest match' ' + mkrepo nest/outer 1 && + mkrepo nest/inner 2 && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "repo.url=a" && + echo "repo.path=$PWD/nest/outer/.git" && + echo "repo.url=a/b" && + echo "repo.path=$PWD/nest/inner/.git" + } >nestrc && + cgit_ok nestrc "url=a/b/log/" >tmp && + test_grep "data-page=.log. data-repo=.a/b." tmp && + test_grep "commit 2" tmp && + cgit_ok nestrc "url=a/log/" >tmp && + test_grep "data-page=.log. data-repo=.a." tmp && + test_grep ! "commit 2" tmp && + cgit_ok nestrc "url=a/b/tree/file-1" >tmp && + test_grep "data-page=.tree. data-repo=.a/b." tmp +' + test_done -- cgit 2.12.1