Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0205-config.sh | 36 |
1 file changed, 36 insertions, 0 deletions
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</a>" 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</a>" 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 |
