author | Lars Hjemli <hjemli@gmail.com> | 2010-09-27 05:58:01 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-09-27 05:58:13 (UTC) |
commit | 82a883ede7e47616aba041a5eb36e08666ef9177 (patch) (unidiff) | |
tree | 14acc2bad5ca5375aa08cb946788b6923d72df7c | |
parent | aaa3f7854232726d5530f66b9459e036bbba15cb (diff) | |
download | cgit-82a883ede7e47616aba041a5eb36e08666ef9177.zip cgit-82a883ede7e47616aba041a5eb36e08666ef9177.tar.gz cgit-82a883ede7e47616aba041a5eb36e08666ef9177.tar.bz2 |
Use GIT-1.7.3
This fixes http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2010-2542.
Noticed-by: Silvio Cesare <silvio.cesare@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | cgit.c | 2 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | ui-plain.c | 2 | ||||
-rw-r--r-- | ui-stats.c | 8 |
5 files changed, 8 insertions, 8 deletions
@@ -1,32 +1,32 @@ | |||
1 | CGIT_VERSION = v0.8.3.3 | 1 | CGIT_VERSION = v0.8.3.3 |
2 | CGIT_SCRIPT_NAME = cgit.cgi | 2 | CGIT_SCRIPT_NAME = cgit.cgi |
3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit | 3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit |
4 | CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) | 4 | CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) |
5 | CGIT_CONFIG = /etc/cgitrc | 5 | CGIT_CONFIG = /etc/cgitrc |
6 | CACHE_ROOT = /var/cache/cgit | 6 | CACHE_ROOT = /var/cache/cgit |
7 | SHA1_HEADER = <openssl/sha.h> | 7 | SHA1_HEADER = <openssl/sha.h> |
8 | GIT_VER = 1.6.4.3 | 8 | GIT_VER = 1.7.3 |
9 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 | 9 | GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 |
10 | INSTALL = install | 10 | INSTALL = install |
11 | 11 | ||
12 | # Define NO_STRCASESTR if you don't have strcasestr. | 12 | # Define NO_STRCASESTR if you don't have strcasestr. |
13 | # | 13 | # |
14 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). | 14 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). |
15 | # | 15 | # |
16 | 16 | ||
17 | #-include config.mak | 17 | #-include config.mak |
18 | 18 | ||
19 | # | 19 | # |
20 | # Platform specific tweaks | 20 | # Platform specific tweaks |
21 | # | 21 | # |
22 | 22 | ||
23 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') | 23 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') |
24 | uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') | 24 | uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') |
25 | uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') | 25 | uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') |
26 | 26 | ||
27 | ifeq ($(uname_O),Cygwin) | 27 | ifeq ($(uname_O),Cygwin) |
28 | NO_STRCASESTR = YesPlease | 28 | NO_STRCASESTR = YesPlease |
29 | NEEDS_LIBICONV = YesPlease | 29 | NEEDS_LIBICONV = YesPlease |
30 | endif | 30 | endif |
31 | 31 | ||
32 | # | 32 | # |
@@ -47,49 +47,49 @@ else # "make -w" | |||
47 | NO_SUBDIR = : | 47 | NO_SUBDIR = : |
48 | endif | 48 | endif |
49 | 49 | ||
50 | ifndef V | 50 | ifndef V |
51 | QUIET_CC = @echo ' ' CC $@; | 51 | QUIET_CC = @echo ' ' CC $@; |
52 | QUIET_MM = @echo ' ' MM $@; | 52 | QUIET_MM = @echo ' ' MM $@; |
53 | QUIET_SUBDIR0 = +@subdir= | 53 | QUIET_SUBDIR0 = +@subdir= |
54 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ | 54 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ |
55 | $(MAKE) $(PRINT_DIR) -C $$subdir | 55 | $(MAKE) $(PRINT_DIR) -C $$subdir |
56 | endif | 56 | endif |
57 | 57 | ||
58 | # | 58 | # |
59 | # Define a pattern rule for automatic dependency building | 59 | # Define a pattern rule for automatic dependency building |
60 | # | 60 | # |
61 | %.d: %.c | 61 | %.d: %.c |
62 | $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ | 62 | $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ |
63 | 63 | ||
64 | # | 64 | # |
65 | # Define a pattern rule for silent object building | 65 | # Define a pattern rule for silent object building |
66 | # | 66 | # |
67 | %.o: %.c | 67 | %.o: %.c |
68 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< | 68 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< |
69 | 69 | ||
70 | 70 | ||
71 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto | 71 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto -lpthread |
72 | OBJECTS = | 72 | OBJECTS = |
73 | OBJECTS += cache.o | 73 | OBJECTS += cache.o |
74 | OBJECTS += cgit.o | 74 | OBJECTS += cgit.o |
75 | OBJECTS += cmd.o | 75 | OBJECTS += cmd.o |
76 | OBJECTS += configfile.o | 76 | OBJECTS += configfile.o |
77 | OBJECTS += html.o | 77 | OBJECTS += html.o |
78 | OBJECTS += parsing.o | 78 | OBJECTS += parsing.o |
79 | OBJECTS += scan-tree.o | 79 | OBJECTS += scan-tree.o |
80 | OBJECTS += shared.o | 80 | OBJECTS += shared.o |
81 | OBJECTS += ui-atom.o | 81 | OBJECTS += ui-atom.o |
82 | OBJECTS += ui-blob.o | 82 | OBJECTS += ui-blob.o |
83 | OBJECTS += ui-clone.o | 83 | OBJECTS += ui-clone.o |
84 | OBJECTS += ui-commit.o | 84 | OBJECTS += ui-commit.o |
85 | OBJECTS += ui-diff.o | 85 | OBJECTS += ui-diff.o |
86 | OBJECTS += ui-log.o | 86 | OBJECTS += ui-log.o |
87 | OBJECTS += ui-patch.o | 87 | OBJECTS += ui-patch.o |
88 | OBJECTS += ui-plain.o | 88 | OBJECTS += ui-plain.o |
89 | OBJECTS += ui-refs.o | 89 | OBJECTS += ui-refs.o |
90 | OBJECTS += ui-repolist.o | 90 | OBJECTS += ui-repolist.o |
91 | OBJECTS += ui-shared.o | 91 | OBJECTS += ui-shared.o |
92 | OBJECTS += ui-snapshot.o | 92 | OBJECTS += ui-snapshot.o |
93 | OBJECTS += ui-stats.o | 93 | OBJECTS += ui-stats.o |
94 | OBJECTS += ui-summary.o | 94 | OBJECTS += ui-summary.o |
95 | OBJECTS += ui-tag.o | 95 | OBJECTS += ui-tag.o |
@@ -1,48 +1,48 @@ | |||
1 | /* cgit.c: cgi for the git scm | 1 | /* cgit.c: cgi for the git scm |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "cache.h" | 10 | #include "cache.h" |
11 | #include "cmd.h" | 11 | #include "cmd.h" |
12 | #include "configfile.h" | 12 | #include "configfile.h" |
13 | #include "html.h" | 13 | #include "html.h" |
14 | #include "ui-shared.h" | 14 | #include "ui-shared.h" |
15 | #include "ui-stats.h" | 15 | #include "ui-stats.h" |
16 | #include "scan-tree.h" | 16 | #include "scan-tree.h" |
17 | 17 | ||
18 | const char *cgit_version = CGIT_VERSION; | 18 | const char *cgit_version = CGIT_VERSION; |
19 | 19 | ||
20 | void add_mimetype(const char *name, const char *value) | 20 | void add_mimetype(const char *name, const char *value) |
21 | { | 21 | { |
22 | struct string_list_item *item; | 22 | struct string_list_item *item; |
23 | 23 | ||
24 | item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); | 24 | item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name)); |
25 | item->util = xstrdup(value); | 25 | item->util = xstrdup(value); |
26 | } | 26 | } |
27 | 27 | ||
28 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | 28 | struct cgit_filter *new_filter(const char *cmd, int extra_args) |
29 | { | 29 | { |
30 | struct cgit_filter *f; | 30 | struct cgit_filter *f; |
31 | 31 | ||
32 | if (!cmd || !cmd[0]) | 32 | if (!cmd || !cmd[0]) |
33 | return NULL; | 33 | return NULL; |
34 | 34 | ||
35 | f = xmalloc(sizeof(struct cgit_filter)); | 35 | f = xmalloc(sizeof(struct cgit_filter)); |
36 | f->cmd = xstrdup(cmd); | 36 | f->cmd = xstrdup(cmd); |
37 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); | 37 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); |
38 | f->argv[0] = f->cmd; | 38 | f->argv[0] = f->cmd; |
39 | f->argv[1] = NULL; | 39 | f->argv[1] = NULL; |
40 | return f; | 40 | return f; |
41 | } | 41 | } |
42 | 42 | ||
43 | static void process_cached_repolist(const char *path); | 43 | static void process_cached_repolist(const char *path); |
44 | 44 | ||
45 | void repo_config(struct cgit_repo *repo, const char *name, const char *value) | 45 | void repo_config(struct cgit_repo *repo, const char *name, const char *value) |
46 | { | 46 | { |
47 | if (!strcmp(name, "name")) | 47 | if (!strcmp(name, "name")) |
48 | repo->name = xstrdup(value); | 48 | repo->name = xstrdup(value); |
diff --git a/git b/git | |||
Subproject 7fb6bcff2dece2ff9fbc5ebfe526d9b2a7e764c | Subproject 87b50542a08ac6caa083ddc376e674424e37940 | ||
@@ -14,49 +14,49 @@ char *curr_rev; | |||
14 | char *match_path; | 14 | char *match_path; |
15 | int match; | 15 | int match; |
16 | 16 | ||
17 | static void print_object(const unsigned char *sha1, const char *path) | 17 | static void print_object(const unsigned char *sha1, const char *path) |
18 | { | 18 | { |
19 | enum object_type type; | 19 | enum object_type type; |
20 | char *buf, *ext; | 20 | char *buf, *ext; |
21 | unsigned long size; | 21 | unsigned long size; |
22 | struct string_list_item *mime; | 22 | struct string_list_item *mime; |
23 | 23 | ||
24 | type = sha1_object_info(sha1, &size); | 24 | type = sha1_object_info(sha1, &size); |
25 | if (type == OBJ_BAD) { | 25 | if (type == OBJ_BAD) { |
26 | html_status(404, "Not found", 0); | 26 | html_status(404, "Not found", 0); |
27 | return; | 27 | return; |
28 | } | 28 | } |
29 | 29 | ||
30 | buf = read_sha1_file(sha1, &type, &size); | 30 | buf = read_sha1_file(sha1, &type, &size); |
31 | if (!buf) { | 31 | if (!buf) { |
32 | html_status(404, "Not found", 0); | 32 | html_status(404, "Not found", 0); |
33 | return; | 33 | return; |
34 | } | 34 | } |
35 | ctx.page.mimetype = NULL; | 35 | ctx.page.mimetype = NULL; |
36 | ext = strrchr(path, '.'); | 36 | ext = strrchr(path, '.'); |
37 | if (ext && *(++ext)) { | 37 | if (ext && *(++ext)) { |
38 | mime = string_list_lookup(ext, &ctx.cfg.mimetypes); | 38 | mime = string_list_lookup(&ctx.cfg.mimetypes, ext); |
39 | if (mime) | 39 | if (mime) |
40 | ctx.page.mimetype = (char *)mime->util; | 40 | ctx.page.mimetype = (char *)mime->util; |
41 | } | 41 | } |
42 | if (!ctx.page.mimetype) { | 42 | if (!ctx.page.mimetype) { |
43 | if (buffer_is_binary(buf, size)) | 43 | if (buffer_is_binary(buf, size)) |
44 | ctx.page.mimetype = "application/octet-stream"; | 44 | ctx.page.mimetype = "application/octet-stream"; |
45 | else | 45 | else |
46 | ctx.page.mimetype = "text/plain"; | 46 | ctx.page.mimetype = "text/plain"; |
47 | } | 47 | } |
48 | ctx.page.filename = fmt("%s", path); | 48 | ctx.page.filename = fmt("%s", path); |
49 | ctx.page.size = size; | 49 | ctx.page.size = size; |
50 | ctx.page.etag = sha1_to_hex(sha1); | 50 | ctx.page.etag = sha1_to_hex(sha1); |
51 | cgit_print_http_headers(&ctx); | 51 | cgit_print_http_headers(&ctx); |
52 | html_raw(buf, size); | 52 | html_raw(buf, size); |
53 | match = 1; | 53 | match = 1; |
54 | } | 54 | } |
55 | 55 | ||
56 | static int walk_tree(const unsigned char *sha1, const char *base, int baselen, | 56 | static int walk_tree(const unsigned char *sha1, const char *base, int baselen, |
57 | const char *pathname, unsigned mode, int stage, | 57 | const char *pathname, unsigned mode, int stage, |
58 | void *cbdata) | 58 | void *cbdata) |
59 | { | 59 | { |
60 | if (S_ISDIR(mode)) | 60 | if (S_ISDIR(mode)) |
61 | return READ_TREE_RECURSIVE; | 61 | return READ_TREE_RECURSIVE; |
62 | 62 | ||
@@ -154,60 +154,60 @@ int cgit_find_stats_period(const char *expr, struct cgit_period **period) | |||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | const char *cgit_find_stats_periodname(int idx) | 157 | const char *cgit_find_stats_periodname(int idx) |
158 | { | 158 | { |
159 | if (idx > 0 && idx < 4) | 159 | if (idx > 0 && idx < 4) |
160 | return periods[idx - 1].name; | 160 | return periods[idx - 1].name; |
161 | else | 161 | else |
162 | return ""; | 162 | return ""; |
163 | } | 163 | } |
164 | 164 | ||
165 | static void add_commit(struct string_list *authors, struct commit *commit, | 165 | static void add_commit(struct string_list *authors, struct commit *commit, |
166 | struct cgit_period *period) | 166 | struct cgit_period *period) |
167 | { | 167 | { |
168 | struct commitinfo *info; | 168 | struct commitinfo *info; |
169 | struct string_list_item *author, *item; | 169 | struct string_list_item *author, *item; |
170 | struct authorstat *authorstat; | 170 | struct authorstat *authorstat; |
171 | struct string_list *items; | 171 | struct string_list *items; |
172 | char *tmp; | 172 | char *tmp; |
173 | struct tm *date; | 173 | struct tm *date; |
174 | time_t t; | 174 | time_t t; |
175 | 175 | ||
176 | info = cgit_parse_commit(commit); | 176 | info = cgit_parse_commit(commit); |
177 | tmp = xstrdup(info->author); | 177 | tmp = xstrdup(info->author); |
178 | author = string_list_insert(tmp, authors); | 178 | author = string_list_insert(authors, tmp); |
179 | if (!author->util) | 179 | if (!author->util) |
180 | author->util = xcalloc(1, sizeof(struct authorstat)); | 180 | author->util = xcalloc(1, sizeof(struct authorstat)); |
181 | else | 181 | else |
182 | free(tmp); | 182 | free(tmp); |
183 | authorstat = author->util; | 183 | authorstat = author->util; |
184 | items = &authorstat->list; | 184 | items = &authorstat->list; |
185 | t = info->committer_date; | 185 | t = info->committer_date; |
186 | date = gmtime(&t); | 186 | date = gmtime(&t); |
187 | period->trunc(date); | 187 | period->trunc(date); |
188 | tmp = xstrdup(period->pretty(date)); | 188 | tmp = xstrdup(period->pretty(date)); |
189 | item = string_list_insert(tmp, items); | 189 | item = string_list_insert(items, tmp); |
190 | if (item->util) | 190 | if (item->util) |
191 | free(tmp); | 191 | free(tmp); |
192 | item->util++; | 192 | item->util++; |
193 | authorstat->total++; | 193 | authorstat->total++; |
194 | cgit_free_commitinfo(info); | 194 | cgit_free_commitinfo(info); |
195 | } | 195 | } |
196 | 196 | ||
197 | static int cmp_total_commits(const void *a1, const void *a2) | 197 | static int cmp_total_commits(const void *a1, const void *a2) |
198 | { | 198 | { |
199 | const struct string_list_item *i1 = a1; | 199 | const struct string_list_item *i1 = a1; |
200 | const struct string_list_item *i2 = a2; | 200 | const struct string_list_item *i2 = a2; |
201 | const struct authorstat *auth1 = i1->util; | 201 | const struct authorstat *auth1 = i1->util; |
202 | const struct authorstat *auth2 = i2->util; | 202 | const struct authorstat *auth2 = i2->util; |
203 | 203 | ||
204 | return auth2->total - auth1->total; | 204 | return auth2->total - auth1->total; |
205 | } | 205 | } |
206 | 206 | ||
207 | /* Walk the commit DAG and collect number of commits per author per | 207 | /* Walk the commit DAG and collect number of commits per author per |
208 | * timeperiod into a nested string_list collection. | 208 | * timeperiod into a nested string_list collection. |
209 | */ | 209 | */ |
210 | struct string_list collect_stats(struct cgit_context *ctx, | 210 | struct string_list collect_stats(struct cgit_context *ctx, |
211 | struct cgit_period *period) | 211 | struct cgit_period *period) |
212 | { | 212 | { |
213 | struct string_list authors; | 213 | struct string_list authors; |
@@ -258,49 +258,49 @@ void print_combined_authorrow(struct string_list *authors, int from, int to, | |||
258 | struct string_list *items; | 258 | struct string_list *items; |
259 | struct string_list_item *date; | 259 | struct string_list_item *date; |
260 | time_t now; | 260 | time_t now; |
261 | long i, j, total, subtotal; | 261 | long i, j, total, subtotal; |
262 | struct tm *tm; | 262 | struct tm *tm; |
263 | char *tmp; | 263 | char *tmp; |
264 | 264 | ||
265 | time(&now); | 265 | time(&now); |
266 | tm = gmtime(&now); | 266 | tm = gmtime(&now); |
267 | period->trunc(tm); | 267 | period->trunc(tm); |
268 | for (i = 1; i < period->count; i++) | 268 | for (i = 1; i < period->count; i++) |
269 | period->dec(tm); | 269 | period->dec(tm); |
270 | 270 | ||
271 | total = 0; | 271 | total = 0; |
272 | htmlf("<tr><td class='%s'>%s</td>", leftclass, | 272 | htmlf("<tr><td class='%s'>%s</td>", leftclass, |
273 | fmt(name, to - from + 1)); | 273 | fmt(name, to - from + 1)); |
274 | for (j = 0; j < period->count; j++) { | 274 | for (j = 0; j < period->count; j++) { |
275 | tmp = period->pretty(tm); | 275 | tmp = period->pretty(tm); |
276 | period->inc(tm); | 276 | period->inc(tm); |
277 | subtotal = 0; | 277 | subtotal = 0; |
278 | for (i = from; i <= to; i++) { | 278 | for (i = from; i <= to; i++) { |
279 | author = &authors->items[i]; | 279 | author = &authors->items[i]; |
280 | authorstat = author->util; | 280 | authorstat = author->util; |
281 | items = &authorstat->list; | 281 | items = &authorstat->list; |
282 | date = string_list_lookup(tmp, items); | 282 | date = string_list_lookup(items, tmp); |
283 | if (date) | 283 | if (date) |
284 | subtotal += (size_t)date->util; | 284 | subtotal += (size_t)date->util; |
285 | } | 285 | } |
286 | htmlf("<td class='%s'>%d</td>", centerclass, subtotal); | 286 | htmlf("<td class='%s'>%d</td>", centerclass, subtotal); |
287 | total += subtotal; | 287 | total += subtotal; |
288 | } | 288 | } |
289 | htmlf("<td class='%s'>%d</td></tr>", rightclass, total); | 289 | htmlf("<td class='%s'>%d</td></tr>", rightclass, total); |
290 | } | 290 | } |
291 | 291 | ||
292 | void print_authors(struct string_list *authors, int top, | 292 | void print_authors(struct string_list *authors, int top, |
293 | struct cgit_period *period) | 293 | struct cgit_period *period) |
294 | { | 294 | { |
295 | struct string_list_item *author; | 295 | struct string_list_item *author; |
296 | struct authorstat *authorstat; | 296 | struct authorstat *authorstat; |
297 | struct string_list *items; | 297 | struct string_list *items; |
298 | struct string_list_item *date; | 298 | struct string_list_item *date; |
299 | time_t now; | 299 | time_t now; |
300 | long i, j, total; | 300 | long i, j, total; |
301 | struct tm *tm; | 301 | struct tm *tm; |
302 | char *tmp; | 302 | char *tmp; |
303 | 303 | ||
304 | time(&now); | 304 | time(&now); |
305 | tm = gmtime(&now); | 305 | tm = gmtime(&now); |
306 | period->trunc(tm); | 306 | period->trunc(tm); |
@@ -310,49 +310,49 @@ void print_authors(struct string_list *authors, int top, | |||
310 | html("<table class='stats'><tr><th>Author</th>"); | 310 | html("<table class='stats'><tr><th>Author</th>"); |
311 | for (j = 0; j < period->count; j++) { | 311 | for (j = 0; j < period->count; j++) { |
312 | tmp = period->pretty(tm); | 312 | tmp = period->pretty(tm); |
313 | htmlf("<th>%s</th>", tmp); | 313 | htmlf("<th>%s</th>", tmp); |
314 | period->inc(tm); | 314 | period->inc(tm); |
315 | } | 315 | } |
316 | html("<th>Total</th></tr>\n"); | 316 | html("<th>Total</th></tr>\n"); |
317 | 317 | ||
318 | if (top <= 0 || top > authors->nr) | 318 | if (top <= 0 || top > authors->nr) |
319 | top = authors->nr; | 319 | top = authors->nr; |
320 | 320 | ||
321 | for (i = 0; i < top; i++) { | 321 | for (i = 0; i < top; i++) { |
322 | author = &authors->items[i]; | 322 | author = &authors->items[i]; |
323 | html("<tr><td class='left'>"); | 323 | html("<tr><td class='left'>"); |
324 | html_txt(author->string); | 324 | html_txt(author->string); |
325 | html("</td>"); | 325 | html("</td>"); |
326 | authorstat = author->util; | 326 | authorstat = author->util; |
327 | items = &authorstat->list; | 327 | items = &authorstat->list; |
328 | total = 0; | 328 | total = 0; |
329 | for (j = 0; j < period->count; j++) | 329 | for (j = 0; j < period->count; j++) |
330 | period->dec(tm); | 330 | period->dec(tm); |
331 | for (j = 0; j < period->count; j++) { | 331 | for (j = 0; j < period->count; j++) { |
332 | tmp = period->pretty(tm); | 332 | tmp = period->pretty(tm); |
333 | period->inc(tm); | 333 | period->inc(tm); |
334 | date = string_list_lookup(tmp, items); | 334 | date = string_list_lookup(items, tmp); |
335 | if (!date) | 335 | if (!date) |
336 | html("<td>0</td>"); | 336 | html("<td>0</td>"); |
337 | else { | 337 | else { |
338 | htmlf("<td>%d</td>", date->util); | 338 | htmlf("<td>%d</td>", date->util); |
339 | total += (size_t)date->util; | 339 | total += (size_t)date->util; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | htmlf("<td class='sum'>%d</td></tr>", total); | 342 | htmlf("<td class='sum'>%d</td></tr>", total); |
343 | } | 343 | } |
344 | 344 | ||
345 | if (top < authors->nr) | 345 | if (top < authors->nr) |
346 | print_combined_authorrow(authors, top, authors->nr - 1, | 346 | print_combined_authorrow(authors, top, authors->nr - 1, |
347 | "Others (%d)", "left", "", "sum", period); | 347 | "Others (%d)", "left", "", "sum", period); |
348 | 348 | ||
349 | print_combined_authorrow(authors, 0, authors->nr - 1, "Total", | 349 | print_combined_authorrow(authors, 0, authors->nr - 1, "Total", |
350 | "total", "sum", "sum", period); | 350 | "total", "sum", "sum", period); |
351 | html("</table>"); | 351 | html("</table>"); |
352 | } | 352 | } |
353 | 353 | ||
354 | /* Create a sorted string_list with one entry per author. The util-field | 354 | /* Create a sorted string_list with one entry per author. The util-field |
355 | * for each author is another string_list which is used to calculate the | 355 | * for each author is another string_list which is used to calculate the |
356 | * number of commits per time-interval. | 356 | * number of commits per time-interval. |
357 | */ | 357 | */ |
358 | void cgit_show_stats(struct cgit_context *ctx) | 358 | void cgit_show_stats(struct cgit_context *ctx) |