author | Lars Hjemli <hjemli@gmail.com> | 2006-12-16 13:58:20 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2006-12-16 13:58:20 (UTC) |
commit | aaa24bdd30303128bded8487cd9f63b54c3b8dcd (patch) (unidiff) | |
tree | 0fd8b32643c205d819f98a827eca3e78fad21bfa | |
parent | fa82b03e05366e3c6ca1b74c8c83d6e00e0ef1e6 (diff) | |
download | cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.zip cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.tar.gz cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.tar.bz2 |
Add cgit_free_commitinfo() and use where needed
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | shared.c | 10 | ||||
-rw-r--r-- | ui-commit.c | 5 | ||||
-rw-r--r-- | ui-log.c | 5 | ||||
-rw-r--r-- | ui-summary.c | 1 |
5 files changed, 15 insertions, 8 deletions
@@ -1,105 +1,107 @@ | |||
1 | #ifndef CGIT_H | 1 | #ifndef CGIT_H |
2 | #define CGIT_H | 2 | #define CGIT_H |
3 | 3 | ||
4 | #include "git.h" | 4 | #include "git.h" |
5 | #include <openssl/sha.h> | 5 | #include <openssl/sha.h> |
6 | #include <ctype.h> | 6 | #include <ctype.h> |
7 | #include <sched.h> | 7 | #include <sched.h> |
8 | 8 | ||
9 | typedef void (*configfn)(const char *name, const char *value); | 9 | typedef void (*configfn)(const char *name, const char *value); |
10 | 10 | ||
11 | struct cacheitem { | 11 | struct cacheitem { |
12 | char *name; | 12 | char *name; |
13 | struct stat st; | 13 | struct stat st; |
14 | int ttl; | 14 | int ttl; |
15 | int fd; | 15 | int fd; |
16 | }; | 16 | }; |
17 | 17 | ||
18 | struct commitinfo { | 18 | struct commitinfo { |
19 | struct commit *commit; | 19 | struct commit *commit; |
20 | char *author; | 20 | char *author; |
21 | char *author_email; | 21 | char *author_email; |
22 | unsigned long author_date; | 22 | unsigned long author_date; |
23 | char *committer; | 23 | char *committer; |
24 | char *committer_email; | 24 | char *committer_email; |
25 | unsigned long committer_date; | 25 | unsigned long committer_date; |
26 | char *subject; | 26 | char *subject; |
27 | char *msg; | 27 | char *msg; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | extern const char cgit_version[]; | 30 | extern const char cgit_version[]; |
31 | 31 | ||
32 | extern char *cgit_root; | 32 | extern char *cgit_root; |
33 | extern char *cgit_root_title; | 33 | extern char *cgit_root_title; |
34 | extern char *cgit_css; | 34 | extern char *cgit_css; |
35 | extern char *cgit_logo; | 35 | extern char *cgit_logo; |
36 | extern char *cgit_logo_link; | 36 | extern char *cgit_logo_link; |
37 | extern char *cgit_virtual_root; | 37 | extern char *cgit_virtual_root; |
38 | extern char *cgit_cache_root; | 38 | extern char *cgit_cache_root; |
39 | 39 | ||
40 | extern int cgit_nocache; | 40 | extern int cgit_nocache; |
41 | extern int cgit_max_lock_attempts; | 41 | extern int cgit_max_lock_attempts; |
42 | extern int cgit_cache_root_ttl; | 42 | extern int cgit_cache_root_ttl; |
43 | extern int cgit_cache_repo_ttl; | 43 | extern int cgit_cache_repo_ttl; |
44 | extern int cgit_cache_dynamic_ttl; | 44 | extern int cgit_cache_dynamic_ttl; |
45 | extern int cgit_cache_static_ttl; | 45 | extern int cgit_cache_static_ttl; |
46 | extern int cgit_cache_max_create_time; | 46 | extern int cgit_cache_max_create_time; |
47 | 47 | ||
48 | extern char *cgit_repo_name; | 48 | extern char *cgit_repo_name; |
49 | extern char *cgit_repo_desc; | 49 | extern char *cgit_repo_desc; |
50 | extern char *cgit_repo_owner; | 50 | extern char *cgit_repo_owner; |
51 | 51 | ||
52 | extern int cgit_query_has_symref; | 52 | extern int cgit_query_has_symref; |
53 | extern int cgit_query_has_sha1; | 53 | extern int cgit_query_has_sha1; |
54 | 54 | ||
55 | extern char *cgit_querystring; | 55 | extern char *cgit_querystring; |
56 | extern char *cgit_query_repo; | 56 | extern char *cgit_query_repo; |
57 | extern char *cgit_query_page; | 57 | extern char *cgit_query_page; |
58 | extern char *cgit_query_head; | 58 | extern char *cgit_query_head; |
59 | extern char *cgit_query_sha1; | 59 | extern char *cgit_query_sha1; |
60 | extern int cgit_query_ofs; | 60 | extern int cgit_query_ofs; |
61 | 61 | ||
62 | extern int htmlfd; | 62 | extern int htmlfd; |
63 | 63 | ||
64 | extern void cgit_global_config_cb(const char *name, const char *value); | 64 | extern void cgit_global_config_cb(const char *name, const char *value); |
65 | extern void cgit_repo_config_cb(const char *name, const char *value); | 65 | extern void cgit_repo_config_cb(const char *name, const char *value); |
66 | extern void cgit_querystring_cb(const char *name, const char *value); | 66 | extern void cgit_querystring_cb(const char *name, const char *value); |
67 | 67 | ||
68 | extern void *cgit_free_commitinfo(struct commitinfo *info); | ||
69 | |||
68 | extern char *fmt(const char *format,...); | 70 | extern char *fmt(const char *format,...); |
69 | 71 | ||
70 | extern void html(const char *txt); | 72 | extern void html(const char *txt); |
71 | extern void htmlf(const char *format,...); | 73 | extern void htmlf(const char *format,...); |
72 | extern void html_txt(char *txt); | 74 | extern void html_txt(char *txt); |
73 | extern void html_attr(char *txt); | 75 | extern void html_attr(char *txt); |
74 | extern void html_link_open(char *url, char *title, char *class); | 76 | extern void html_link_open(char *url, char *title, char *class); |
75 | extern void html_link_close(void); | 77 | extern void html_link_close(void); |
76 | 78 | ||
77 | extern int cgit_read_config(const char *filename, configfn fn); | 79 | extern int cgit_read_config(const char *filename, configfn fn); |
78 | extern int cgit_parse_query(char *txt, configfn fn); | 80 | extern int cgit_parse_query(char *txt, configfn fn); |
79 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 81 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
80 | 82 | ||
81 | extern void cache_prepare(struct cacheitem *item); | 83 | extern void cache_prepare(struct cacheitem *item); |
82 | extern int cache_lock(struct cacheitem *item); | 84 | extern int cache_lock(struct cacheitem *item); |
83 | extern int cache_unlock(struct cacheitem *item); | 85 | extern int cache_unlock(struct cacheitem *item); |
84 | extern int cache_cancel_lock(struct cacheitem *item); | 86 | extern int cache_cancel_lock(struct cacheitem *item); |
85 | extern int cache_exist(struct cacheitem *item); | 87 | extern int cache_exist(struct cacheitem *item); |
86 | extern int cache_expired(struct cacheitem *item); | 88 | extern int cache_expired(struct cacheitem *item); |
87 | 89 | ||
88 | extern char *cgit_repourl(const char *reponame); | 90 | extern char *cgit_repourl(const char *reponame); |
89 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 91 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
90 | const char *query); | 92 | const char *query); |
91 | 93 | ||
92 | extern void cgit_print_error(char *msg); | 94 | extern void cgit_print_error(char *msg); |
93 | extern void cgit_print_date(unsigned long secs); | 95 | extern void cgit_print_date(unsigned long secs); |
94 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 96 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
95 | extern void cgit_print_docend(); | 97 | extern void cgit_print_docend(); |
96 | extern void cgit_print_pageheader(char *title); | 98 | extern void cgit_print_pageheader(char *title); |
97 | 99 | ||
98 | extern void cgit_print_repolist(struct cacheitem *item); | 100 | extern void cgit_print_repolist(struct cacheitem *item); |
99 | extern void cgit_print_summary(); | 101 | extern void cgit_print_summary(); |
100 | extern void cgit_print_log(const char *tip, int ofs, int cnt); | 102 | extern void cgit_print_log(const char *tip, int ofs, int cnt); |
101 | extern void cgit_print_view(const char *hex); | 103 | extern void cgit_print_view(const char *hex); |
102 | extern void cgit_print_tree(const char *hex); | 104 | extern void cgit_print_tree(const char *hex); |
103 | extern void cgit_print_commit(const char *hex); | 105 | extern void cgit_print_commit(const char *hex); |
104 | 106 | ||
105 | #endif /* CGIT_H */ | 107 | #endif /* CGIT_H */ |
@@ -1,90 +1,100 @@ | |||
1 | /* shared.c: global vars + some callback functions | 1 | /* shared.c: global vars + some callback functions |
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 | 10 | ||
11 | char *cgit_root = "/usr/src/git"; | 11 | char *cgit_root = "/usr/src/git"; |
12 | char *cgit_root_title = "Git repository browser"; | 12 | char *cgit_root_title = "Git repository browser"; |
13 | char *cgit_css = "/cgit.css"; | 13 | char *cgit_css = "/cgit.css"; |
14 | char *cgit_logo = "/git-logo.png"; | 14 | char *cgit_logo = "/git-logo.png"; |
15 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; | 15 | char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; |
16 | char *cgit_virtual_root = NULL; | 16 | char *cgit_virtual_root = NULL; |
17 | 17 | ||
18 | char *cgit_cache_root = "/var/cache/cgit"; | 18 | char *cgit_cache_root = "/var/cache/cgit"; |
19 | 19 | ||
20 | int cgit_nocache = 0; | 20 | int cgit_nocache = 0; |
21 | int cgit_max_lock_attempts = 5; | 21 | int cgit_max_lock_attempts = 5; |
22 | int cgit_cache_root_ttl = 5; | 22 | int cgit_cache_root_ttl = 5; |
23 | int cgit_cache_repo_ttl = 5; | 23 | int cgit_cache_repo_ttl = 5; |
24 | int cgit_cache_dynamic_ttl = 5; | 24 | int cgit_cache_dynamic_ttl = 5; |
25 | int cgit_cache_static_ttl = -1; | 25 | int cgit_cache_static_ttl = -1; |
26 | int cgit_cache_max_create_time = 5; | 26 | int cgit_cache_max_create_time = 5; |
27 | 27 | ||
28 | char *cgit_repo_name = NULL; | 28 | char *cgit_repo_name = NULL; |
29 | char *cgit_repo_desc = NULL; | 29 | char *cgit_repo_desc = NULL; |
30 | char *cgit_repo_owner = NULL; | 30 | char *cgit_repo_owner = NULL; |
31 | 31 | ||
32 | int cgit_query_has_symref = 0; | 32 | int cgit_query_has_symref = 0; |
33 | int cgit_query_has_sha1 = 0; | 33 | int cgit_query_has_sha1 = 0; |
34 | 34 | ||
35 | char *cgit_querystring = NULL; | 35 | char *cgit_querystring = NULL; |
36 | char *cgit_query_repo = NULL; | 36 | char *cgit_query_repo = NULL; |
37 | char *cgit_query_page = NULL; | 37 | char *cgit_query_page = NULL; |
38 | char *cgit_query_head = NULL; | 38 | char *cgit_query_head = NULL; |
39 | char *cgit_query_sha1 = NULL; | 39 | char *cgit_query_sha1 = NULL; |
40 | int cgit_query_ofs = 0; | 40 | int cgit_query_ofs = 0; |
41 | 41 | ||
42 | int htmlfd = 0; | 42 | int htmlfd = 0; |
43 | 43 | ||
44 | void cgit_global_config_cb(const char *name, const char *value) | 44 | void cgit_global_config_cb(const char *name, const char *value) |
45 | { | 45 | { |
46 | if (!strcmp(name, "root")) | 46 | if (!strcmp(name, "root")) |
47 | cgit_root = xstrdup(value); | 47 | cgit_root = xstrdup(value); |
48 | else if (!strcmp(name, "root-title")) | 48 | else if (!strcmp(name, "root-title")) |
49 | cgit_root_title = xstrdup(value); | 49 | cgit_root_title = xstrdup(value); |
50 | else if (!strcmp(name, "css")) | 50 | else if (!strcmp(name, "css")) |
51 | cgit_css = xstrdup(value); | 51 | cgit_css = xstrdup(value); |
52 | else if (!strcmp(name, "logo")) | 52 | else if (!strcmp(name, "logo")) |
53 | cgit_logo = xstrdup(value); | 53 | cgit_logo = xstrdup(value); |
54 | else if (!strcmp(name, "logo-link")) | 54 | else if (!strcmp(name, "logo-link")) |
55 | cgit_logo_link = xstrdup(value); | 55 | cgit_logo_link = xstrdup(value); |
56 | else if (!strcmp(name, "virtual-root")) | 56 | else if (!strcmp(name, "virtual-root")) |
57 | cgit_virtual_root = xstrdup(value); | 57 | cgit_virtual_root = xstrdup(value); |
58 | else if (!strcmp(name, "nocache")) | 58 | else if (!strcmp(name, "nocache")) |
59 | cgit_nocache = atoi(value); | 59 | cgit_nocache = atoi(value); |
60 | else if (!strcmp(name, "cache-root")) | 60 | else if (!strcmp(name, "cache-root")) |
61 | cgit_cache_root = xstrdup(value); | 61 | cgit_cache_root = xstrdup(value); |
62 | } | 62 | } |
63 | 63 | ||
64 | void cgit_repo_config_cb(const char *name, const char *value) | 64 | void cgit_repo_config_cb(const char *name, const char *value) |
65 | { | 65 | { |
66 | if (!strcmp(name, "name")) | 66 | if (!strcmp(name, "name")) |
67 | cgit_repo_name = xstrdup(value); | 67 | cgit_repo_name = xstrdup(value); |
68 | else if (!strcmp(name, "desc")) | 68 | else if (!strcmp(name, "desc")) |
69 | cgit_repo_desc = xstrdup(value); | 69 | cgit_repo_desc = xstrdup(value); |
70 | else if (!strcmp(name, "owner")) | 70 | else if (!strcmp(name, "owner")) |
71 | cgit_repo_owner = xstrdup(value); | 71 | cgit_repo_owner = xstrdup(value); |
72 | } | 72 | } |
73 | 73 | ||
74 | void cgit_querystring_cb(const char *name, const char *value) | 74 | void cgit_querystring_cb(const char *name, const char *value) |
75 | { | 75 | { |
76 | if (!strcmp(name,"r")) { | 76 | if (!strcmp(name,"r")) { |
77 | cgit_query_repo = xstrdup(value); | 77 | cgit_query_repo = xstrdup(value); |
78 | } else if (!strcmp(name, "p")) { | 78 | } else if (!strcmp(name, "p")) { |
79 | cgit_query_page = xstrdup(value); | 79 | cgit_query_page = xstrdup(value); |
80 | } else if (!strcmp(name, "h")) { | 80 | } else if (!strcmp(name, "h")) { |
81 | cgit_query_head = xstrdup(value); | 81 | cgit_query_head = xstrdup(value); |
82 | cgit_query_has_symref = 1; | 82 | cgit_query_has_symref = 1; |
83 | } else if (!strcmp(name, "id")) { | 83 | } else if (!strcmp(name, "id")) { |
84 | cgit_query_sha1 = xstrdup(value); | 84 | cgit_query_sha1 = xstrdup(value); |
85 | cgit_query_has_sha1 = 1; | 85 | cgit_query_has_sha1 = 1; |
86 | } else if (!strcmp(name, "ofs")) { | 86 | } else if (!strcmp(name, "ofs")) { |
87 | cgit_query_ofs = atoi(value); | 87 | cgit_query_ofs = atoi(value); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void *cgit_free_commitinfo(struct commitinfo *info) | ||
92 | { | ||
93 | free(info->author); | ||
94 | free(info->author_email); | ||
95 | free(info->committer); | ||
96 | free(info->committer_email); | ||
97 | free(info->subject); | ||
98 | free(info); | ||
99 | return NULL; | ||
100 | } | ||
diff --git a/ui-commit.c b/ui-commit.c index b441e14..f654208 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -1,68 +1,65 @@ | |||
1 | /* ui-commit.c: generate commit view | 1 | /* ui-commit.c: generate commit view |
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 | 10 | ||
11 | void cgit_print_commit(const char *hex) | 11 | void cgit_print_commit(const char *hex) |
12 | { | 12 | { |
13 | struct commit *commit; | 13 | struct commit *commit; |
14 | struct commitinfo *info; | 14 | struct commitinfo *info; |
15 | struct commit_list *p; | 15 | struct commit_list *p; |
16 | 16 | ||
17 | unsigned char sha1[20]; | 17 | unsigned char sha1[20]; |
18 | 18 | ||
19 | if (get_sha1(hex, sha1)) { | 19 | if (get_sha1(hex, sha1)) { |
20 | cgit_print_error(fmt("Bad object id: %s", hex)); | 20 | cgit_print_error(fmt("Bad object id: %s", hex)); |
21 | return; | 21 | return; |
22 | } | 22 | } |
23 | 23 | ||
24 | commit = lookup_commit_reference(sha1); | 24 | commit = lookup_commit_reference(sha1); |
25 | if (!commit) { | 25 | if (!commit) { |
26 | cgit_print_error(fmt("Bad commit reference: %s", hex)); | 26 | cgit_print_error(fmt("Bad commit reference: %s", hex)); |
27 | return; | 27 | return; |
28 | } | 28 | } |
29 | 29 | ||
30 | info = cgit_parse_commit(commit); | 30 | info = cgit_parse_commit(commit); |
31 | 31 | ||
32 | html("<table class='commit-info'>\n"); | 32 | html("<table class='commit-info'>\n"); |
33 | html("<tr><th>author</th><td>"); | 33 | html("<tr><th>author</th><td>"); |
34 | html_txt(info->author); | 34 | html_txt(info->author); |
35 | html(" "); | 35 | html(" "); |
36 | html_txt(info->author_email); | 36 | html_txt(info->author_email); |
37 | html("</td><td class='right'>"); | 37 | html("</td><td class='right'>"); |
38 | cgit_print_date(info->author_date); | 38 | cgit_print_date(info->author_date); |
39 | html("</td></tr>\n"); | 39 | html("</td></tr>\n"); |
40 | html("<tr><th>committer</th><td>"); | 40 | html("<tr><th>committer</th><td>"); |
41 | html_txt(info->committer); | 41 | html_txt(info->committer); |
42 | html(" "); | 42 | html(" "); |
43 | html_txt(info->committer_email); | 43 | html_txt(info->committer_email); |
44 | html("</td><td class='right'>"); | 44 | html("</td><td class='right'>"); |
45 | cgit_print_date(info->committer_date); | 45 | cgit_print_date(info->committer_date); |
46 | html("</td></tr>\n"); | 46 | html("</td></tr>\n"); |
47 | html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); | 47 | html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); |
48 | html_attr(cgit_pageurl(cgit_query_repo, "tree", fmt("id=%s", sha1_to_hex(commit->tree->object.sha1)))); | 48 | html_attr(cgit_pageurl(cgit_query_repo, "tree", fmt("id=%s", sha1_to_hex(commit->tree->object.sha1)))); |
49 | htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); | 49 | htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); |
50 | 50 | ||
51 | for (p = commit->parents; p ; p = p->next) { | 51 | for (p = commit->parents; p ; p = p->next) { |
52 | html("<tr><th>parent</th><td colspan='2' class='sha1'><a href='"); | 52 | html("<tr><th>parent</th><td colspan='2' class='sha1'><a href='"); |
53 | html_attr(cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(p->item->object.sha1)))); | 53 | html_attr(cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(p->item->object.sha1)))); |
54 | htmlf("'>%s</a></td></tr>\n", | 54 | htmlf("'>%s</a></td></tr>\n", |
55 | sha1_to_hex(p->item->object.sha1)); | 55 | sha1_to_hex(p->item->object.sha1)); |
56 | } | 56 | } |
57 | html("</table>\n"); | 57 | html("</table>\n"); |
58 | html("<div class='commit-subject'>"); | 58 | html("<div class='commit-subject'>"); |
59 | html_txt(info->subject); | 59 | html_txt(info->subject); |
60 | html("</div>"); | 60 | html("</div>"); |
61 | html("<div class='commit-msg'>"); | 61 | html("<div class='commit-msg'>"); |
62 | html_txt(info->msg); | 62 | html_txt(info->msg); |
63 | html("</div>"); | 63 | html("</div>"); |
64 | free(info->author); | 64 | cgit_free_commitinfo(info); |
65 | free(info->committer); | ||
66 | free(info->subject); | ||
67 | free(info); | ||
68 | } | 65 | } |
@@ -1,92 +1,89 @@ | |||
1 | /* ui-log.c: functions for log output | 1 | /* ui-log.c: functions for log output |
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 | 10 | ||
11 | void print_commit(struct commit *commit) | 11 | void print_commit(struct commit *commit) |
12 | { | 12 | { |
13 | char buf[32]; | 13 | char buf[32]; |
14 | struct commitinfo *info; | 14 | struct commitinfo *info; |
15 | struct tm *time; | 15 | struct tm *time; |
16 | 16 | ||
17 | info = cgit_parse_commit(commit); | 17 | info = cgit_parse_commit(commit); |
18 | time = gmtime(&commit->date); | 18 | time = gmtime(&commit->date); |
19 | html("<tr><td>"); | 19 | html("<tr><td>"); |
20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); | 20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |
21 | html_txt(buf); | 21 | html_txt(buf); |
22 | html("</td><td>"); | 22 | html("</td><td>"); |
23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); | 23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); | 24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); |
25 | html_link_open(url, NULL, NULL); | 25 | html_link_open(url, NULL, NULL); |
26 | html_txt(info->subject); | 26 | html_txt(info->subject); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | html_txt(info->author); | 29 | html_txt(info->author); |
30 | html("</td></tr>\n"); | 30 | html("</td></tr>\n"); |
31 | free(info->author); | 31 | cgit_free_commitinfo(info); |
32 | free(info->committer); | ||
33 | free(info->subject); | ||
34 | free(info); | ||
35 | } | 32 | } |
36 | 33 | ||
37 | 34 | ||
38 | void cgit_print_log(const char *tip, int ofs, int cnt) | 35 | void cgit_print_log(const char *tip, int ofs, int cnt) |
39 | { | 36 | { |
40 | struct rev_info rev; | 37 | struct rev_info rev; |
41 | struct commit *commit; | 38 | struct commit *commit; |
42 | const char *argv[2] = {NULL, tip}; | 39 | const char *argv[2] = {NULL, tip}; |
43 | int i; | 40 | int i; |
44 | 41 | ||
45 | init_revisions(&rev, NULL); | 42 | init_revisions(&rev, NULL); |
46 | rev.abbrev = DEFAULT_ABBREV; | 43 | rev.abbrev = DEFAULT_ABBREV; |
47 | rev.commit_format = CMIT_FMT_DEFAULT; | 44 | rev.commit_format = CMIT_FMT_DEFAULT; |
48 | rev.verbose_header = 1; | 45 | rev.verbose_header = 1; |
49 | rev.show_root_diff = 0; | 46 | rev.show_root_diff = 0; |
50 | setup_revisions(2, argv, &rev, NULL); | 47 | setup_revisions(2, argv, &rev, NULL); |
51 | prepare_revision_walk(&rev); | 48 | prepare_revision_walk(&rev); |
52 | 49 | ||
53 | html("<h2>Log</h2>"); | 50 | html("<h2>Log</h2>"); |
54 | html("<table class='list log'>"); | 51 | html("<table class='list log'>"); |
55 | html("<tr><th class='left'>Date</th><th class='left'>Message</th><th class='left'>Author</th></tr>\n"); | 52 | html("<tr><th class='left'>Date</th><th class='left'>Message</th><th class='left'>Author</th></tr>\n"); |
56 | 53 | ||
57 | if (ofs<0) | 54 | if (ofs<0) |
58 | ofs = 0; | 55 | ofs = 0; |
59 | 56 | ||
60 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 57 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
61 | free(commit->buffer); | 58 | free(commit->buffer); |
62 | commit->buffer = NULL; | 59 | commit->buffer = NULL; |
63 | free_commit_list(commit->parents); | 60 | free_commit_list(commit->parents); |
64 | commit->parents = NULL; | 61 | commit->parents = NULL; |
65 | } | 62 | } |
66 | 63 | ||
67 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 64 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
68 | print_commit(commit); | 65 | print_commit(commit); |
69 | free(commit->buffer); | 66 | free(commit->buffer); |
70 | commit->buffer = NULL; | 67 | commit->buffer = NULL; |
71 | free_commit_list(commit->parents); | 68 | free_commit_list(commit->parents); |
72 | commit->parents = NULL; | 69 | commit->parents = NULL; |
73 | } | 70 | } |
74 | html("</table>\n"); | 71 | html("</table>\n"); |
75 | 72 | ||
76 | html("<div class='pager'>"); | 73 | html("<div class='pager'>"); |
77 | if (ofs > 0) { | 74 | if (ofs > 0) { |
78 | html(" <a href='"); | 75 | html(" <a href='"); |
79 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, | 76 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, |
80 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); | 77 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); |
81 | html("'>[prev]</a> "); | 78 | html("'>[prev]</a> "); |
82 | } | 79 | } |
83 | 80 | ||
84 | if ((commit = get_revision(&rev)) != NULL) { | 81 | if ((commit = get_revision(&rev)) != NULL) { |
85 | html(" <a href='"); | 82 | html(" <a href='"); |
86 | html(cgit_pageurl(cgit_query_repo, "log", | 83 | html(cgit_pageurl(cgit_query_repo, "log", |
87 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); | 84 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); |
88 | html("'>[next]</a> "); | 85 | html("'>[next]</a> "); |
89 | } | 86 | } |
90 | html("</div>"); | 87 | html("</div>"); |
91 | } | 88 | } |
92 | 89 | ||
diff --git a/ui-summary.c b/ui-summary.c index 8ff3642..5ddeee3 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -1,62 +1,63 @@ | |||
1 | /* ui-summary.c: functions for generating repo summary page | 1 | /* ui-summary.c: functions for generating repo summary page |
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 | 10 | ||
11 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | 11 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, |
12 | int flags, void *cb_data) | 12 | int flags, void *cb_data) |
13 | { | 13 | { |
14 | struct commit *commit; | 14 | struct commit *commit; |
15 | struct commitinfo *info; | 15 | struct commitinfo *info; |
16 | char buf[256], *url; | 16 | char buf[256], *url; |
17 | 17 | ||
18 | commit = lookup_commit(sha1); | 18 | commit = lookup_commit(sha1); |
19 | if (commit && !parse_commit(commit)){ | 19 | if (commit && !parse_commit(commit)){ |
20 | info = cgit_parse_commit(commit); | 20 | info = cgit_parse_commit(commit); |
21 | html("<tr><td>"); | 21 | html("<tr><td>"); |
22 | url = cgit_pageurl(cgit_query_repo, "log", | 22 | url = cgit_pageurl(cgit_query_repo, "log", |
23 | fmt("h=%s", refname)); | 23 | fmt("h=%s", refname)); |
24 | html_link_open(url, NULL, NULL); | 24 | html_link_open(url, NULL, NULL); |
25 | strncpy(buf, refname, sizeof(buf)); | 25 | strncpy(buf, refname, sizeof(buf)); |
26 | html_txt(buf); | 26 | html_txt(buf); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | cgit_print_date(commit->date); | 29 | cgit_print_date(commit->date); |
30 | html("</td><td>"); | 30 | html("</td><td>"); |
31 | url = cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(sha1))); | 31 | url = cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(sha1))); |
32 | html_link_open(url, NULL, NULL); | 32 | html_link_open(url, NULL, NULL); |
33 | html_txt(info->subject); | 33 | html_txt(info->subject); |
34 | html_link_close(); | 34 | html_link_close(); |
35 | html("</td><td>"); | 35 | html("</td><td>"); |
36 | html_txt(info->author); | 36 | html_txt(info->author); |
37 | html("</td></tr>\n"); | 37 | html("</td></tr>\n"); |
38 | cgit_free_commitinfo(info); | ||
38 | } else { | 39 | } else { |
39 | html("<tr><td>"); | 40 | html("<tr><td>"); |
40 | html_txt(buf); | 41 | html_txt(buf); |
41 | html("</td><td>"); | 42 | html("</td><td>"); |
42 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); | 43 | htmlf("*** bad ref %s", sha1_to_hex(sha1)); |
43 | html("</td></tr>\n"); | 44 | html("</td></tr>\n"); |
44 | } | 45 | } |
45 | return 0; | 46 | return 0; |
46 | } | 47 | } |
47 | 48 | ||
48 | static void cgit_print_branches() | 49 | static void cgit_print_branches() |
49 | { | 50 | { |
50 | html("<table class='list'>"); | 51 | html("<table class='list'>"); |
51 | html("<tr><th class='left'>Branch</th><th class='left'>Updated</th><th class='left'>Commit subject</th><th class='left'>Author</th></tr>\n"); | 52 | html("<tr><th class='left'>Branch</th><th class='left'>Updated</th><th class='left'>Commit subject</th><th class='left'>Author</th></tr>\n"); |
52 | for_each_branch_ref(cgit_print_branch_cb, NULL); | 53 | for_each_branch_ref(cgit_print_branch_cb, NULL); |
53 | html("</table>"); | 54 | html("</table>"); |
54 | } | 55 | } |
55 | 56 | ||
56 | void cgit_print_summary() | 57 | void cgit_print_summary() |
57 | { | 58 | { |
58 | html("<h2>"); | 59 | html("<h2>"); |
59 | html_txt("Repo summary page"); | 60 | html_txt("Repo summary page"); |
60 | html("</h2>"); | 61 | html("</h2>"); |
61 | cgit_print_branches(); | 62 | cgit_print_branches(); |
62 | } | 63 | } |