diff options
-rw-r--r-- | Makefile | 2 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | html.c | 20 | ||||
-rwxr-xr-x | tests/setup.sh | 18 | ||||
-rwxr-xr-x | tests/t0010-validate-html.sh | 5 | ||||
-rwxr-xr-x | tests/t0101-index.sh | 6 | ||||
-rwxr-xr-x | tests/t0102-summary.sh | 6 | ||||
-rwxr-xr-x | tests/t0108-patch.sh | 37 | ||||
-rw-r--r-- | ui-patch.c | 6 |
9 files changed, 72 insertions, 28 deletions
diff --git a/Makefile b/Makefile index 355186e..931c60e 100644 --- a/Makefile +++ b/Makefile | |||
@@ -4,7 +4,7 @@ CGIT_SCRIPT_PATH = /var/www/htdocs/cgit | |||
4 | CGIT_CONFIG = /etc/cgitrc | 4 | CGIT_CONFIG = /etc/cgitrc |
5 | CACHE_ROOT = /var/cache/cgit | 5 | CACHE_ROOT = /var/cache/cgit |
6 | SHA1_HEADER = <openssl/sha.h> | 6 | SHA1_HEADER = <openssl/sha.h> |
7 | GIT_VER = 1.5.4.1 | 7 | GIT_VER = 1.5.5.rc1 |
8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 | 8 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 |
9 | 9 | ||
10 | # | 10 | # |
diff --git a/git b/git | |||
Subproject 527270689c364bea9b0630df9bae5e09c2071c1 | Subproject 803d5158123346229d71de53818920efbc88ca0 | ||
diff --git a/html.c b/html.c index 98ffaf9..937b5e7 100644 --- a/html.c +++ b/html.c | |||
@@ -56,9 +56,7 @@ void html_txt(char *txt) | |||
56 | while(t && *t){ | 56 | while(t && *t){ |
57 | int c = *t; | 57 | int c = *t; |
58 | if (c=='<' || c=='>' || c=='&') { | 58 | if (c=='<' || c=='>' || c=='&') { |
59 | *t = '\0'; | 59 | write(htmlfd, txt, t - txt); |
60 | html(txt); | ||
61 | *t = c; | ||
62 | if (c=='>') | 60 | if (c=='>') |
63 | html(">"); | 61 | html(">"); |
64 | else if (c=='<') | 62 | else if (c=='<') |
@@ -79,9 +77,7 @@ void html_ntxt(int len, char *txt) | |||
79 | while(t && *t && len--){ | 77 | while(t && *t && len--){ |
80 | int c = *t; | 78 | int c = *t; |
81 | if (c=='<' || c=='>' || c=='&') { | 79 | if (c=='<' || c=='>' || c=='&') { |
82 | *t = '\0'; | 80 | write(htmlfd, txt, t - txt); |
83 | html(txt); | ||
84 | *t = c; | ||
85 | if (c=='>') | 81 | if (c=='>') |
86 | html(">"); | 82 | html(">"); |
87 | else if (c=='<') | 83 | else if (c=='<') |
@@ -92,12 +88,8 @@ void html_ntxt(int len, char *txt) | |||
92 | } | 88 | } |
93 | t++; | 89 | t++; |
94 | } | 90 | } |
95 | if (t!=txt) { | 91 | if (t!=txt) |
96 | char c = *t; | 92 | write(htmlfd, txt, t - txt); |
97 | *t = '\0'; | ||
98 | html(txt); | ||
99 | *t = c; | ||
100 | } | ||
101 | if (len<0) | 93 | if (len<0) |
102 | html("..."); | 94 | html("..."); |
103 | } | 95 | } |
@@ -108,9 +100,7 @@ void html_attr(char *txt) | |||
108 | while(t && *t){ | 100 | while(t && *t){ |
109 | int c = *t; | 101 | int c = *t; |
110 | if (c=='<' || c=='>' || c=='\'') { | 102 | if (c=='<' || c=='>' || c=='\'') { |
111 | *t = '\0'; | 103 | write(htmlfd, txt, t - txt); |
112 | html(txt); | ||
113 | *t = c; | ||
114 | if (c=='>') | 104 | if (c=='>') |
115 | html(">"); | 105 | html(">"); |
116 | else if (c=='<') | 106 | else if (c=='<') |
diff --git a/tests/setup.sh b/tests/setup.sh index 51d5a75..66bf406 100755 --- a/tests/setup.sh +++ b/tests/setup.sh | |||
@@ -54,7 +54,9 @@ summary-tags=5 | |||
54 | 54 | ||
55 | repo.url=foo | 55 | repo.url=foo |
56 | repo.path=$PWD/trash/repos/foo/.git | 56 | repo.path=$PWD/trash/repos/foo/.git |
57 | repo.desc=the foo repo | 57 | # Do not specify a description for this repo, as it then will be assigned |
58 | # the constant value "[no description]" (which actually used to cause a | ||
59 | # segfault). | ||
58 | 60 | ||
59 | repo.url=bar | 61 | repo.url=bar |
60 | repo.path=$PWD/trash/repos/bar/.git | 62 | repo.path=$PWD/trash/repos/bar/.git |
@@ -65,8 +67,10 @@ EOF | |||
65 | prepare_tests() | 67 | prepare_tests() |
66 | { | 68 | { |
67 | setup_repos | 69 | setup_repos |
70 | rm -f test-output.log 2>/dev/null | ||
68 | test_count=0 | 71 | test_count=0 |
69 | test_failed=0 | 72 | test_failed=0 |
73 | echo "[$0]" "$@" >test-output.log | ||
70 | echo "$@" "($0)" | 74 | echo "$@" "($0)" |
71 | } | 75 | } |
72 | 76 | ||
@@ -75,7 +79,8 @@ tests_done() | |||
75 | printf "\n" | 79 | printf "\n" |
76 | if test $test_failed -gt 0 | 80 | if test $test_failed -gt 0 |
77 | then | 81 | then |
78 | printf "[%s of %s tests failed]\n" $test_failed $test_count | 82 | printf "test: *** %s failure(s), logfile=%s\n" \ |
83 | $test_failed "$(pwd)/test-output.log" | ||
79 | false | 84 | false |
80 | fi | 85 | fi |
81 | } | 86 | } |
@@ -85,14 +90,17 @@ run_test() | |||
85 | desc=$1 | 90 | desc=$1 |
86 | script=$2 | 91 | script=$2 |
87 | ((test_count++)) | 92 | ((test_count++)) |
88 | eval "$2" >test-output.log | 93 | printf "\ntest %d: name='%s'\n" $test_count "$desc" >>test-output.log |
94 | printf "test %d: eval='%s'\n" $test_count "$2" >>test-output.log | ||
95 | eval "$2" >>test-output.log 2>>test-output.log | ||
89 | res=$? | 96 | res=$? |
97 | printf "test %d: exitcode=%d\n" $test_count $res >>test-output.log | ||
90 | if test $res = 0 | 98 | if test $res = 0 |
91 | then | 99 | then |
92 | printf " %s: ok - %s\n" $test_count "$desc" | 100 | printf " %2d) %-60s [ok]\n" $test_count "$desc" |
93 | else | 101 | else |
94 | ((test_failed++)) | 102 | ((test_failed++)) |
95 | printf " %s: fail - %s\n" $test_count "$desc" | 103 | printf " %2d) %-60s [failed]\n" $test_count "$desc" |
96 | fi | 104 | fi |
97 | } | 105 | } |
98 | 106 | ||
diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh index 907a415..94aa52b 100755 --- a/tests/t0010-validate-html.sh +++ b/tests/t0010-validate-html.sh | |||
@@ -7,9 +7,12 @@ test_url() | |||
7 | { | 7 | { |
8 | tidy_opt="-eq" | 8 | tidy_opt="-eq" |
9 | test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no" | 9 | test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no" |
10 | cgit_url "$1" | sed -e "1,4d" >trash/tidy-$test_count | 10 | cgit_url "$1" >trash/tidy-$test_count || return |
11 | sed -ie "1,4d" trash/tidy-$test_count || return | ||
11 | tidy $tidy_opt trash/tidy-$test_count | 12 | tidy $tidy_opt trash/tidy-$test_count |
12 | rc=$? | 13 | rc=$? |
14 | |||
15 | # tidy returns with exitcode 1 on warnings, 2 on error | ||
13 | if test $rc = 2 | 16 | if test $rc = 2 |
14 | then | 17 | then |
15 | false | 18 | false |
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index 12ed00c..445af6a 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh | |||
@@ -6,8 +6,10 @@ prepare_tests "Check content on index page" | |||
6 | 6 | ||
7 | run_test 'generate index page' 'cgit_url "" >trash/tmp' | 7 | run_test 'generate index page' 'cgit_url "" >trash/tmp' |
8 | run_test 'find foo repo' 'grep -e "foo" trash/tmp' | 8 | run_test 'find foo repo' 'grep -e "foo" trash/tmp' |
9 | run_test 'find foo description' 'grep -e "\[no description\]" trash/tmp' | ||
9 | run_test 'find bar repo' 'grep -e "bar" trash/tmp' | 10 | run_test 'find bar repo' 'grep -e "bar" trash/tmp' |
10 | run_test 'no tree-link' 'grep -ve "foo/tree" trash/tmp' | 11 | run_test 'find bar description' 'grep -e "the bar repo" trash/tmp' |
11 | run_test 'no log-link' 'grep -ve "foo/log" trash/tmp' | 12 | run_test 'no tree-link' '! grep -e "foo/tree" trash/tmp' |
13 | run_test 'no log-link' '! grep -e "foo/log" trash/tmp' | ||
12 | 14 | ||
13 | tests_done | 15 | tests_done |
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh index 7edd675..f0b0d9a 100755 --- a/tests/t0102-summary.sh +++ b/tests/t0102-summary.sh | |||
@@ -8,13 +8,13 @@ run_test 'generate foo summary' 'cgit_url "foo" >trash/tmp' | |||
8 | run_test 'find commit 1' 'grep -e "commit 1" trash/tmp' | 8 | run_test 'find commit 1' 'grep -e "commit 1" trash/tmp' |
9 | run_test 'find commit 5' 'grep -e "commit 5" trash/tmp' | 9 | run_test 'find commit 5' 'grep -e "commit 5" trash/tmp' |
10 | run_test 'find branch master' 'grep -e "master" trash/tmp' | 10 | run_test 'find branch master' 'grep -e "master" trash/tmp' |
11 | run_test 'no tags' 'grep -ve "tags" trash/tmp' | 11 | run_test 'no tags' '! grep -e "tags" trash/tmp' |
12 | 12 | ||
13 | run_test 'generate bar summary' 'cgit_url "bar" >trash/tmp' | 13 | run_test 'generate bar summary' 'cgit_url "bar" >trash/tmp' |
14 | run_test 'no commit 45' 'grep -ve "commit 45" trash/tmp' | 14 | run_test 'no commit 45' '! grep -e "commit 45" trash/tmp' |
15 | run_test 'find commit 46' 'grep -e "commit 46" trash/tmp' | 15 | run_test 'find commit 46' 'grep -e "commit 46" trash/tmp' |
16 | run_test 'find commit 50' 'grep -e "commit 50" trash/tmp' | 16 | run_test 'find commit 50' 'grep -e "commit 50" trash/tmp' |
17 | run_test 'find branch master' 'grep -e "master" trash/tmp' | 17 | run_test 'find branch master' 'grep -e "master" trash/tmp' |
18 | run_test 'no tags' 'grep -ve "tags" trash/tmp' | 18 | run_test 'no tags' '! grep -e "tags" trash/tmp' |
19 | 19 | ||
20 | tests_done | 20 | tests_done |
diff --git a/tests/t0108-patch.sh b/tests/t0108-patch.sh new file mode 100755 index 0000000..33351d6 --- /dev/null +++ b/tests/t0108-patch.sh | |||
@@ -0,0 +1,37 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | . ./setup.sh | ||
4 | |||
5 | prepare_tests "Check content on patch page" | ||
6 | |||
7 | run_test 'generate foo/patch' ' | ||
8 | cgit_query "url=foo/patch" >trash/tmp | ||
9 | ' | ||
10 | |||
11 | run_test 'find `From:` line' ' | ||
12 | grep -e "^From: " trash/tmp | ||
13 | ' | ||
14 | |||
15 | run_test 'find `Date:` line' ' | ||
16 | grep -e "^Date: " trash/tmp | ||
17 | ' | ||
18 | |||
19 | run_test 'find `Subject:` line' ' | ||
20 | grep -e "^Subject: commit 5" trash/tmp | ||
21 | ' | ||
22 | |||
23 | run_test 'find `cgit` signature' ' | ||
24 | tail -1 trash/tmp | grep -e "^cgit" | ||
25 | ' | ||
26 | |||
27 | run_test 'find initial commit' ' | ||
28 | root=$(git --git-dir=$PWD/trash/repos/foo/.git rev-list HEAD | tail -1) | ||
29 | ' | ||
30 | |||
31 | run_test 'generate patch for initial commit' ' | ||
32 | cgit_query "url=foo/patch&id=$root" >trash/tmp | ||
33 | ' | ||
34 | |||
35 | run_test 'find `cgit` signature' ' | ||
36 | tail -1 trash/tmp | grep -e "^cgit" | ||
37 | ' | ||
diff --git a/ui-patch.c b/ui-patch.c index 36bfae4..c1c4ce3 100644 --- a/ui-patch.c +++ b/ui-patch.c | |||
@@ -90,7 +90,11 @@ void cgit_print_patch(char *hex) | |||
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | info = cgit_parse_commit(commit); | 92 | info = cgit_parse_commit(commit); |
93 | hashcpy(old_sha1, commit->parents->item->object.sha1); | 93 | |
94 | if (commit->parents && commit->parents->item) | ||
95 | hashcpy(old_sha1, commit->parents->item->object.sha1); | ||
96 | else | ||
97 | hashclr(old_sha1); | ||
94 | 98 | ||
95 | patchname = fmt("%s.patch", sha1_to_hex(sha1)); | 99 | patchname = fmt("%s.patch", sha1_to_hex(sha1)); |
96 | ctx.page.mimetype = "text/plain"; | 100 | ctx.page.mimetype = "text/plain"; |