1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
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 "<a href=./foo/tree/.>" tmp'
test_expect_success 'find parent link' 'grep -E "<a href=./foo/commit/\?id=.+>" tmp'
test_expect_success 'find commit subject' '
grep "<div class=.commit-subject.>commit 5<" tmp
'
test_expect_success 'find commit msg' 'grep "<div class=.commit-msg.></div>" tmp'
test_expect_success 'find diffstat' 'grep "<table class=.diffstat.>" 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 "</html>" tmp
'
test_expect_success 'root commit contains diffstat' '
grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40,64\}.>file-1</a>" tmp
'
test_expect_success 'root commit contains diff' '
grep ">diff --git a/file-1 b/file-1<" tmp &&
grep "<div class=.add.>+1</div>" tmp
'
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 <author@example.com> 1735689600 +0000\n" "$tree" >raw &&
printf "committer A U Thor <author@example.com> 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 "<div class=.commit-subject.>caf? subject<" tmp &&
grep "body ? end" tmp &&
! grep "caf$(printf "\351")" tmp
'
test_done
|