From a3bb7c69c0295cb2fc7909559456e798b222fccd Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:56:59 -0700 Subject: Add the shared config writers and cgit_rc The helpers are named by kind. cgitrc_repo and cgitrc_copy write the config file named first, and cgit_url, cgit_query and cgit_rc run cgit, each named after what it is handed first. A repository copies its defaults from the globals read before its repo.url, so cgitrc_repo places every setting itself, and a global can no longer land where it silently stops applying. The t00xx and t01xx files move to them here. --- tests/t0105-plain.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'tests/t0105-plain.sh') diff --git a/tests/t0105-plain.sh b/tests/t0105-plain.sh index 4615dc5..6a96b61 100755 --- a/tests/t0105-plain.sh +++ b/tests/t0105-plain.sh @@ -65,9 +65,9 @@ test_expect_success 'only text and xml types carry a charset' ' echo "mimetype.svg=image/svg+xml" && cat cgitrc } >typesrc && - CGIT_CONFIG="$PWD/typesrc" QUERY_STRING="url=foo/plain/doc.docx" cgit >tmp && + cgit_rc typesrc "url=foo/plain/doc.docx" >tmp && sed "/^$/q" tmp | grep "^Content-Type: $docx$" && - CGIT_CONFIG="$PWD/typesrc" QUERY_STRING="url=foo/plain/pic.svg" cgit >tmp && + cgit_rc typesrc "url=foo/plain/pic.svg" >tmp && sed "/^$/q" tmp | grep "^Content-Type: image/svg+xml; charset=UTF-8$" ' @@ -83,14 +83,8 @@ test_expect_success 'plain answers once for duplicate tree entries' ' c=$(echo dup | git commit-tree $top) && git update-ref refs/heads/master $c ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "mimetype.png=image/png" && - echo "repo.url=dup" && - echo "repo.path=$PWD/repos/dup/.git" - } >duprc && - CGIT_CONFIG="$PWD/duprc" QUERY_STRING="url=dup/plain/x.png" cgit >tmp && + cgitrc_repo duprc dup mimetype.png=image/png && + cgit_rc duprc "url=dup/plain/x.png" >tmp && test $(grep -c "^Status:" tmp) = 1 && test $(grep -c "^Content-Type:" tmp) = 1 && grep "^Content-Type: image/png" tmp @@ -106,7 +100,7 @@ test_expect_success 'a control character in a file name stays out of the headers c=$(echo ctl | git commit-tree $top) && git update-ref refs/heads/ctl $c ) && - CGIT_CONFIG="$PWD/duprc" QUERY_STRING="url=dup/plain/ctl%01name.txt&h=ctl" cgit >tmp && + cgit_rc duprc "url=dup/plain/ctl%01name.txt&h=ctl" >tmp && grep "^Content-Disposition: inline; filename=.ctl?name.txt.$" tmp ' -- cgit