Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Hold hand-written refs to the files backend
A loose ref written by hand needs the files backend, so under
GIT_TEST_DEFAULT_REF_FORMAT=reftable the broken tree test failed, and
the die test after it with it, since it borrowed that clone. It now
makes its own. Both index tests that stat a path through refs/heads
also passed there with their checks gone, as reftable keeps
refs/heads as a file. The commit is rewritten through files rather
than a pipeline that hid cat-file failing.
| -rwxr-xr-x | tests/t0303-robustness.sh | 36 |
1 file changed, 20 insertions, 16 deletions
diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index 4cb922d..a6a439b 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -422,26 +422,28 @@ test_expect_success 'a revision expression that walks the history is refused' ' grep "^Status: 200" tmp ' -test_expect_success 'a commit with a broken tree line does not crash the blob page' ' +# git update-ref refuses a ref to an object it cannot parse, so the ref is +# written as a loose file, which only the files backend reads. +test_expect_success REFFILES 'a commit with a broken tree line does not crash the blob page' ' git clone -q repos/rob broken && - ( - cd broken && - bad=$(git cat-file commit HEAD | sed "s/^tree .*/tree not-a-hash/" | - git hash-object -t commit -w --stdin --literally) && - echo $bad >.git/refs/heads/bad - ) && + git -C broken cat-file commit HEAD >commit && + sed "s/^tree .*/tree not-a-hash/" commit >bad-commit && + bad=$(git -C broken hash-object -t commit -w --literally "$PWD/bad-commit") && + echo $bad >broken/.git/refs/heads/bad && cgitrc_repo brokenrc broken "repo.path=$PWD/broken/.git" repo.readme=:file-1 && cgit_rc brokenrc "url=broken/blob/&h=bad&path=file-1" >tmp && - grep "^Status: 404" tmp + test_grep "^Status: 404" tmp ' test_expect_success 'a die inside git answers one 500 page and logs the reason' ' - printf "[core\n" >>broken/.git/config && - cgit_rc brokenrc "url=broken/log/" >tmp 2>err && - grep "^Status: 500" tmp && + git clone -q repos/rob badconfig && + printf "[core\n" >>badconfig/.git/config && + cgitrc_repo badconfigrc badconfig "repo.path=$PWD/badconfig/.git" && + cgit_rc badconfigrc "url=badconfig/log/" >tmp 2>err && + test_grep "^Status: 500" tmp && test $(grep -c "^Status:" tmp) = 1 && - grep "bad config line" err && - ! grep "bad config line" tmp + test_grep "bad config line" err && + test_grep ! "bad config line" tmp ' # The log walks the history before it prints a row, so a missing commit ends @@ -874,7 +876,9 @@ test_expect_success 'a notes ref that names no tree is passed over' ' # A scanned repository names its own default branch, which the index stats # below the repository to date it, so the name is held to what a ref may be. -test_expect_success 'a scanned defbranch cannot name a path outside the repository' ' +# The path runs through refs/heads, which reftable keeps as a file, so only +# the files backend shows the escape. +test_expect_success REFFILES 'a scanned defbranch cannot name a path outside the repository' ' mkdir -p secret && touch -t 200001010000 secret/file && echo "defbranch=../../../../secret/file" >scan/b.git/cgitrc && @@ -884,8 +888,8 @@ test_expect_success 'a scanned defbranch cannot name a path outside the reposito ' # HEAD is a file the repository's owner writes as well, and the index stats -# the branch it names to date the repository. -test_expect_success 'a crafted HEAD cannot date a repository from outside it' ' +# the branch it names below refs/heads to date the repository. +test_expect_success REFFILES 'a crafted HEAD cannot date a repository from outside it' ' mkdir -p aimed && touch -t 200001010000 aimed/file && git init -q --bare headscan/h.git && |
