From beccb842f6e5cc31ddfc8b7b66d899809ad6c2b8 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 19:26:21 -1000 Subject: Report a word where cgitrc expects a number atoi reads "yes" or "true" as 0, so repo.hide=yes, or cgit.hide true in a scanned repository's git config, silently did nothing. The values keep that meaning, since honouring them now would hide repositories on upgrade, but each one is logged with its file and line. --- tests/t0205-config.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests') diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh index 12087e7..3b892e9 100755 --- a/tests/t0205-config.sh +++ b/tests/t0205-config.sh @@ -143,4 +143,40 @@ test_expect_success 'a scan says nothing of the files it may lack' ' test_must_be_empty err ' +# A number is read as atoi reads it, which makes a word 0 without a sound, so +# a value that is not a whole number is logged with the file and line it came +# from, and still read the way it always was. An include in between leaves +# the line count of the file around it alone. +test_expect_success 'a word where a number belongs is reported' ' + cgitrc_repo wordrc word enable-index-owner=no "max-repo-count= 20 " \ + "repo.path=$PWD/repos/foo/.git" repo.hide=yes && + cgit_rc wordrc "url=" >tmp 2>err && + grep ">word" tmp && + ! grep "col-owner" tmp && + grep "Reading enable-index-owner=no in $PWD/wordrc line 3 as 0, since it is not a whole number" err && + grep "Reading hide=yes in $PWD/wordrc line 7 as 0, since it is not a whole number" err && + ! grep "max-repo-count" err && + { + echo "include=$PWD/wordrc" && + echo "enable-blame=on" + } >outerrc && + cgit_rc outerrc "url=" >tmp 2>err && + grep "Reading enable-blame=on in $PWD/outerrc line 2 as 0, since it is not a whole number" err +' + +test_expect_success 'a word in a scanned git config is reported' ' + git clone -q --bare repos/foo/.git wordscan/foo.git && + git -C wordscan/foo.git config cgit.hide true && + line=$(grep -n "hide = true" wordscan/foo.git/config | cut -d: -f1) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "enable-git-config=1" && + echo "scan-path=$PWD/wordscan" + } >wordscanrc && + cgit_rc wordscanrc "url=" >tmp 2>err && + grep ">foo.git" tmp && + grep "Reading hide=true in $PWD/wordscan/foo.git/config line $line as 0, since it is not a whole number" err +' + test_done -- cgit 2.12.1