#!/bin/sh # The commit page. Most checks read the markup for the tree link, the parent # link, the subject and the diffstat. The last few use a root commit, which # has no parent and diffs against the empty tree. test_description='Check content on commit page' . ./setup.sh test_expect_success 'generate foo/commit' 'cgit_url "foo/commit" >tmp' test_expect_success 'find tree link' 'grep "" tmp' test_expect_success 'find parent link' 'grep -E "" tmp' test_expect_success 'find commit subject' ' grep "
commit 5<" tmp ' test_expect_success 'find commit msg' 'grep "
" tmp' test_expect_success 'find diffstat' 'grep "" tmp' test_expect_success 'find diff summary' ' grep "1 file changed, 1 insertion, 0 deletions" tmp ' test_expect_success 'get root commit' ' root=$(cd repos/foo && git rev-list --reverse HEAD | head -1) && cgit_url "foo/commit&id=$root" >tmp && grep "" tmp ' test_expect_success 'root commit contains diffstat' ' grep "file-1" tmp ' test_expect_success 'root commit contains diff' ' grep ">diff --git a/file-1 b/file-1<" tmp && grep "
+1
" tmp ' # A message that is not UTF-8, because its encoding header names something # iconv cannot convert or is missing altogether, would otherwise reach a # page declared UTF-8 as it is, so its stray bytes become question marks. test_expect_success 'a message that is not UTF-8 has its stray bytes replaced' ' ( cd repos/foo && tree=$(git rev-parse HEAD^{tree}) && printf "tree %s\nauthor A U Thor 1735689600 +0000\n" "$tree" >raw && printf "committer A U Thor 1735689600 +0000\n" >>raw && printf "encoding no-such-charset\n\ncaf\351 subject\n\nbody \377 end\n" >>raw && cid=$(git hash-object --literally -t commit -w raw) && git update-ref refs/heads/latin "$cid" ) && cgit_query "url=foo/commit&h=latin" >tmp && grep "
caf? subject<" tmp && grep "body ? end" tmp && ! grep "caf$(printf "\351")" tmp ' test_done