-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | shared.c | 4 | ||||
-rw-r--r-- | ui-log.c | 2 | ||||
-rw-r--r-- | ui-summary.c | 2 |
4 files changed, 8 insertions, 2 deletions
@@ -7,96 +7,98 @@ | |||
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 | struct taginfo { | 30 | struct taginfo { |
31 | char *tagger; | 31 | char *tagger; |
32 | char *tagger_email; | 32 | char *tagger_email; |
33 | int tagger_date; | 33 | int tagger_date; |
34 | char *msg; | 34 | char *msg; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | extern const char cgit_version[]; | 37 | extern const char cgit_version[]; |
38 | 38 | ||
39 | extern char *cgit_root; | 39 | extern char *cgit_root; |
40 | extern char *cgit_root_title; | 40 | extern char *cgit_root_title; |
41 | extern char *cgit_css; | 41 | extern char *cgit_css; |
42 | extern char *cgit_logo; | 42 | extern char *cgit_logo; |
43 | extern char *cgit_logo_link; | 43 | extern char *cgit_logo_link; |
44 | extern char *cgit_virtual_root; | 44 | extern char *cgit_virtual_root; |
45 | extern char *cgit_cache_root; | 45 | extern char *cgit_cache_root; |
46 | 46 | ||
47 | extern int cgit_nocache; | 47 | extern int cgit_nocache; |
48 | extern int cgit_max_lock_attempts; | 48 | extern int cgit_max_lock_attempts; |
49 | extern int cgit_cache_root_ttl; | 49 | extern int cgit_cache_root_ttl; |
50 | extern int cgit_cache_repo_ttl; | 50 | extern int cgit_cache_repo_ttl; |
51 | extern int cgit_cache_dynamic_ttl; | 51 | extern int cgit_cache_dynamic_ttl; |
52 | extern int cgit_cache_static_ttl; | 52 | extern int cgit_cache_static_ttl; |
53 | extern int cgit_cache_max_create_time; | 53 | extern int cgit_cache_max_create_time; |
54 | 54 | ||
55 | extern int cgit_max_msg_len; | ||
56 | |||
55 | extern char *cgit_repo_name; | 57 | extern char *cgit_repo_name; |
56 | extern char *cgit_repo_desc; | 58 | extern char *cgit_repo_desc; |
57 | extern char *cgit_repo_owner; | 59 | extern char *cgit_repo_owner; |
58 | 60 | ||
59 | extern int cgit_query_has_symref; | 61 | extern int cgit_query_has_symref; |
60 | extern int cgit_query_has_sha1; | 62 | extern int cgit_query_has_sha1; |
61 | 63 | ||
62 | extern char *cgit_querystring; | 64 | extern char *cgit_querystring; |
63 | extern char *cgit_query_repo; | 65 | extern char *cgit_query_repo; |
64 | extern char *cgit_query_page; | 66 | extern char *cgit_query_page; |
65 | extern char *cgit_query_search; | 67 | extern char *cgit_query_search; |
66 | extern char *cgit_query_head; | 68 | extern char *cgit_query_head; |
67 | extern char *cgit_query_sha1; | 69 | extern char *cgit_query_sha1; |
68 | extern char *cgit_query_sha2; | 70 | extern char *cgit_query_sha2; |
69 | extern char *cgit_query_path; | 71 | extern char *cgit_query_path; |
70 | extern int cgit_query_ofs; | 72 | extern int cgit_query_ofs; |
71 | 73 | ||
72 | extern int htmlfd; | 74 | extern int htmlfd; |
73 | 75 | ||
74 | extern void cgit_global_config_cb(const char *name, const char *value); | 76 | extern void cgit_global_config_cb(const char *name, const char *value); |
75 | extern void cgit_repo_config_cb(const char *name, const char *value); | 77 | extern void cgit_repo_config_cb(const char *name, const char *value); |
76 | extern void cgit_querystring_cb(const char *name, const char *value); | 78 | extern void cgit_querystring_cb(const char *name, const char *value); |
77 | 79 | ||
78 | extern int hextoint(char c); | 80 | extern int hextoint(char c); |
79 | 81 | ||
80 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 82 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
81 | 83 | ||
82 | extern char *fmt(const char *format,...); | 84 | extern char *fmt(const char *format,...); |
83 | 85 | ||
84 | extern void html(const char *txt); | 86 | extern void html(const char *txt); |
85 | extern void htmlf(const char *format,...); | 87 | extern void htmlf(const char *format,...); |
86 | extern void html_txt(char *txt); | 88 | extern void html_txt(char *txt); |
87 | extern void html_ntxt(int len, char *txt); | 89 | extern void html_ntxt(int len, char *txt); |
88 | extern void html_attr(char *txt); | 90 | extern void html_attr(char *txt); |
89 | extern void html_hidden(char *name, char *value); | 91 | extern void html_hidden(char *name, char *value); |
90 | extern void html_link_open(char *url, char *title, char *class); | 92 | extern void html_link_open(char *url, char *title, char *class); |
91 | extern void html_link_close(void); | 93 | extern void html_link_close(void); |
92 | extern void html_filemode(unsigned short mode); | 94 | extern void html_filemode(unsigned short mode); |
93 | 95 | ||
94 | extern int cgit_read_config(const char *filename, configfn fn); | 96 | extern int cgit_read_config(const char *filename, configfn fn); |
95 | extern int cgit_parse_query(char *txt, configfn fn); | 97 | extern int cgit_parse_query(char *txt, configfn fn); |
96 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 98 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
97 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 99 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
98 | 100 | ||
99 | extern char *cache_safe_filename(const char *unsafe); | 101 | extern char *cache_safe_filename(const char *unsafe); |
100 | extern int cache_lock(struct cacheitem *item); | 102 | extern int cache_lock(struct cacheitem *item); |
101 | extern int cache_unlock(struct cacheitem *item); | 103 | extern int cache_unlock(struct cacheitem *item); |
102 | extern int cache_cancel_lock(struct cacheitem *item); | 104 | extern int cache_cancel_lock(struct cacheitem *item); |
@@ -1,120 +1,124 @@ | |||
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 | int cgit_max_msg_len = 60; | ||
29 | |||
28 | char *cgit_repo_name = NULL; | 30 | char *cgit_repo_name = NULL; |
29 | char *cgit_repo_desc = NULL; | 31 | char *cgit_repo_desc = NULL; |
30 | char *cgit_repo_owner = NULL; | 32 | char *cgit_repo_owner = NULL; |
31 | 33 | ||
32 | int cgit_query_has_symref = 0; | 34 | int cgit_query_has_symref = 0; |
33 | int cgit_query_has_sha1 = 0; | 35 | int cgit_query_has_sha1 = 0; |
34 | 36 | ||
35 | char *cgit_querystring = NULL; | 37 | char *cgit_querystring = NULL; |
36 | char *cgit_query_repo = NULL; | 38 | char *cgit_query_repo = NULL; |
37 | char *cgit_query_page = NULL; | 39 | char *cgit_query_page = NULL; |
38 | char *cgit_query_head = NULL; | 40 | char *cgit_query_head = NULL; |
39 | char *cgit_query_search = NULL; | 41 | char *cgit_query_search = NULL; |
40 | char *cgit_query_sha1 = NULL; | 42 | char *cgit_query_sha1 = NULL; |
41 | char *cgit_query_sha2 = NULL; | 43 | char *cgit_query_sha2 = NULL; |
42 | char *cgit_query_path = NULL; | 44 | char *cgit_query_path = NULL; |
43 | int cgit_query_ofs = 0; | 45 | int cgit_query_ofs = 0; |
44 | 46 | ||
45 | int htmlfd = 0; | 47 | int htmlfd = 0; |
46 | 48 | ||
47 | void cgit_global_config_cb(const char *name, const char *value) | 49 | void cgit_global_config_cb(const char *name, const char *value) |
48 | { | 50 | { |
49 | if (!strcmp(name, "root")) | 51 | if (!strcmp(name, "root")) |
50 | cgit_root = xstrdup(value); | 52 | cgit_root = xstrdup(value); |
51 | else if (!strcmp(name, "root-title")) | 53 | else if (!strcmp(name, "root-title")) |
52 | cgit_root_title = xstrdup(value); | 54 | cgit_root_title = xstrdup(value); |
53 | else if (!strcmp(name, "css")) | 55 | else if (!strcmp(name, "css")) |
54 | cgit_css = xstrdup(value); | 56 | cgit_css = xstrdup(value); |
55 | else if (!strcmp(name, "logo")) | 57 | else if (!strcmp(name, "logo")) |
56 | cgit_logo = xstrdup(value); | 58 | cgit_logo = xstrdup(value); |
57 | else if (!strcmp(name, "logo-link")) | 59 | else if (!strcmp(name, "logo-link")) |
58 | cgit_logo_link = xstrdup(value); | 60 | cgit_logo_link = xstrdup(value); |
59 | else if (!strcmp(name, "virtual-root")) | 61 | else if (!strcmp(name, "virtual-root")) |
60 | cgit_virtual_root = xstrdup(value); | 62 | cgit_virtual_root = xstrdup(value); |
61 | else if (!strcmp(name, "nocache")) | 63 | else if (!strcmp(name, "nocache")) |
62 | cgit_nocache = atoi(value); | 64 | cgit_nocache = atoi(value); |
63 | else if (!strcmp(name, "cache-root")) | 65 | else if (!strcmp(name, "cache-root")) |
64 | cgit_cache_root = xstrdup(value); | 66 | cgit_cache_root = xstrdup(value); |
65 | else if (!strcmp(name, "cache-root-ttl")) | 67 | else if (!strcmp(name, "cache-root-ttl")) |
66 | cgit_cache_root_ttl = atoi(value); | 68 | cgit_cache_root_ttl = atoi(value); |
67 | else if (!strcmp(name, "cache-repo-ttl")) | 69 | else if (!strcmp(name, "cache-repo-ttl")) |
68 | cgit_cache_repo_ttl = atoi(value); | 70 | cgit_cache_repo_ttl = atoi(value); |
69 | else if (!strcmp(name, "cache-static-ttl")) | 71 | else if (!strcmp(name, "cache-static-ttl")) |
70 | cgit_cache_static_ttl = atoi(value); | 72 | cgit_cache_static_ttl = atoi(value); |
71 | else if (!strcmp(name, "cache-dynamic-ttl")) | 73 | else if (!strcmp(name, "cache-dynamic-ttl")) |
72 | cgit_cache_dynamic_ttl = atoi(value); | 74 | cgit_cache_dynamic_ttl = atoi(value); |
75 | else if (!strcmp(name, "max-message-length")) | ||
76 | cgit_max_msg_len = atoi(value); | ||
73 | } | 77 | } |
74 | 78 | ||
75 | void cgit_repo_config_cb(const char *name, const char *value) | 79 | void cgit_repo_config_cb(const char *name, const char *value) |
76 | { | 80 | { |
77 | if (!strcmp(name, "name")) | 81 | if (!strcmp(name, "name")) |
78 | cgit_repo_name = xstrdup(value); | 82 | cgit_repo_name = xstrdup(value); |
79 | else if (!strcmp(name, "desc")) | 83 | else if (!strcmp(name, "desc")) |
80 | cgit_repo_desc = xstrdup(value); | 84 | cgit_repo_desc = xstrdup(value); |
81 | else if (!strcmp(name, "owner")) | 85 | else if (!strcmp(name, "owner")) |
82 | cgit_repo_owner = xstrdup(value); | 86 | cgit_repo_owner = xstrdup(value); |
83 | } | 87 | } |
84 | 88 | ||
85 | void cgit_querystring_cb(const char *name, const char *value) | 89 | void cgit_querystring_cb(const char *name, const char *value) |
86 | { | 90 | { |
87 | if (!strcmp(name,"r")) { | 91 | if (!strcmp(name,"r")) { |
88 | cgit_query_repo = xstrdup(value); | 92 | cgit_query_repo = xstrdup(value); |
89 | } else if (!strcmp(name, "p")) { | 93 | } else if (!strcmp(name, "p")) { |
90 | cgit_query_page = xstrdup(value); | 94 | cgit_query_page = xstrdup(value); |
91 | } else if (!strcmp(name, "q")) { | 95 | } else if (!strcmp(name, "q")) { |
92 | cgit_query_search = xstrdup(value); | 96 | cgit_query_search = xstrdup(value); |
93 | } else if (!strcmp(name, "h")) { | 97 | } else if (!strcmp(name, "h")) { |
94 | cgit_query_head = xstrdup(value); | 98 | cgit_query_head = xstrdup(value); |
95 | cgit_query_has_symref = 1; | 99 | cgit_query_has_symref = 1; |
96 | } else if (!strcmp(name, "id")) { | 100 | } else if (!strcmp(name, "id")) { |
97 | cgit_query_sha1 = xstrdup(value); | 101 | cgit_query_sha1 = xstrdup(value); |
98 | cgit_query_has_sha1 = 1; | 102 | cgit_query_has_sha1 = 1; |
99 | } else if (!strcmp(name, "id2")) { | 103 | } else if (!strcmp(name, "id2")) { |
100 | cgit_query_sha2 = xstrdup(value); | 104 | cgit_query_sha2 = xstrdup(value); |
101 | cgit_query_has_sha1 = 1; | 105 | cgit_query_has_sha1 = 1; |
102 | } else if (!strcmp(name, "ofs")) { | 106 | } else if (!strcmp(name, "ofs")) { |
103 | cgit_query_ofs = atoi(value); | 107 | cgit_query_ofs = atoi(value); |
104 | } else if (!strcmp(name, "path")) { | 108 | } else if (!strcmp(name, "path")) { |
105 | cgit_query_path = xstrdup(value); | 109 | cgit_query_path = xstrdup(value); |
106 | } | 110 | } |
107 | } | 111 | } |
108 | 112 | ||
109 | void *cgit_free_commitinfo(struct commitinfo *info) | 113 | void *cgit_free_commitinfo(struct commitinfo *info) |
110 | { | 114 | { |
111 | free(info->author); | 115 | free(info->author); |
112 | free(info->author_email); | 116 | free(info->author_email); |
113 | free(info->committer); | 117 | free(info->committer); |
114 | free(info->committer_email); | 118 | free(info->committer_email); |
115 | free(info->subject); | 119 | free(info->subject); |
116 | free(info); | 120 | free(info); |
117 | return NULL; | 121 | return NULL; |
118 | } | 122 | } |
119 | 123 | ||
120 | int hextoint(char c) | 124 | int hextoint(char c) |
@@ -1,74 +1,74 @@ | |||
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_ntxt(80, info->subject); | 26 | html_ntxt(cgit_max_msg_len, 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 | cgit_free_commitinfo(info); | 31 | cgit_free_commitinfo(info); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
35 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep) | 35 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep) |
36 | { | 36 | { |
37 | struct rev_info rev; | 37 | struct rev_info rev; |
38 | struct commit *commit; | 38 | struct commit *commit; |
39 | const char *argv[3] = {NULL, tip, NULL}; | 39 | const char *argv[3] = {NULL, tip, NULL}; |
40 | int argc = 2; | 40 | int argc = 2; |
41 | int i; | 41 | int i; |
42 | 42 | ||
43 | if (grep) | 43 | if (grep) |
44 | argv[argc++] = fmt("--grep=%s", grep); | 44 | argv[argc++] = fmt("--grep=%s", grep); |
45 | init_revisions(&rev, NULL); | 45 | init_revisions(&rev, NULL); |
46 | rev.abbrev = DEFAULT_ABBREV; | 46 | rev.abbrev = DEFAULT_ABBREV; |
47 | rev.commit_format = CMIT_FMT_DEFAULT; | 47 | rev.commit_format = CMIT_FMT_DEFAULT; |
48 | rev.verbose_header = 1; | 48 | rev.verbose_header = 1; |
49 | rev.show_root_diff = 0; | 49 | rev.show_root_diff = 0; |
50 | setup_revisions(argc, argv, &rev, NULL); | 50 | setup_revisions(argc, argv, &rev, NULL); |
51 | if (rev.grep_filter) { | 51 | if (rev.grep_filter) { |
52 | rev.grep_filter->regflags |= REG_ICASE; | 52 | rev.grep_filter->regflags |= REG_ICASE; |
53 | compile_grep_patterns(rev.grep_filter); | 53 | compile_grep_patterns(rev.grep_filter); |
54 | } | 54 | } |
55 | prepare_revision_walk(&rev); | 55 | prepare_revision_walk(&rev); |
56 | 56 | ||
57 | html("<h2>Log</h2>"); | 57 | html("<h2>Log</h2>"); |
58 | html("<table class='list nowrap'>"); | 58 | html("<table class='list nowrap'>"); |
59 | html("<tr class='nohover'><th class='left'>Date</th>" | 59 | html("<tr class='nohover'><th class='left'>Date</th>" |
60 | "<th class='left'>Message</th>" | 60 | "<th class='left'>Message</th>" |
61 | "<th class='left'>Author</th></tr>\n"); | 61 | "<th class='left'>Author</th></tr>\n"); |
62 | 62 | ||
63 | if (ofs<0) | 63 | if (ofs<0) |
64 | ofs = 0; | 64 | ofs = 0; |
65 | 65 | ||
66 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 66 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
67 | free(commit->buffer); | 67 | free(commit->buffer); |
68 | commit->buffer = NULL; | 68 | commit->buffer = NULL; |
69 | free_commit_list(commit->parents); | 69 | free_commit_list(commit->parents); |
70 | commit->parents = NULL; | 70 | commit->parents = NULL; |
71 | } | 71 | } |
72 | 72 | ||
73 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 73 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
74 | print_commit(commit); | 74 | print_commit(commit); |
diff --git a/ui-summary.c b/ui-summary.c index 04d4912..5518d01 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -1,84 +1,84 @@ | |||
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 | strncpy(buf, refname, sizeof(buf)); | 18 | strncpy(buf, refname, sizeof(buf)); |
19 | commit = lookup_commit(sha1); | 19 | commit = lookup_commit(sha1); |
20 | if (commit && !parse_commit(commit)){ | 20 | if (commit && !parse_commit(commit)){ |
21 | info = cgit_parse_commit(commit); | 21 | info = cgit_parse_commit(commit); |
22 | html("<tr><td>"); | 22 | html("<tr><td>"); |
23 | url = cgit_pageurl(cgit_query_repo, "log", | 23 | url = cgit_pageurl(cgit_query_repo, "log", |
24 | fmt("h=%s", refname)); | 24 | fmt("h=%s", refname)); |
25 | html_link_open(url, NULL, NULL); | 25 | html_link_open(url, NULL, NULL); |
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 | html_txt(info->author); | 31 | html_txt(info->author); |
32 | html("</td><td>"); | 32 | html("</td><td>"); |
33 | url = cgit_pageurl(cgit_query_repo, "commit", | 33 | url = cgit_pageurl(cgit_query_repo, "commit", |
34 | fmt("id=%s", sha1_to_hex(sha1))); | 34 | fmt("id=%s", sha1_to_hex(sha1))); |
35 | html_link_open(url, NULL, NULL); | 35 | html_link_open(url, NULL, NULL); |
36 | html_ntxt(80, info->subject); | 36 | html_ntxt(cgit_max_msg_len, info->subject); |
37 | html_link_close(); | 37 | html_link_close(); |
38 | html("</td></tr>\n"); | 38 | html("</td></tr>\n"); |
39 | cgit_free_commitinfo(info); | 39 | cgit_free_commitinfo(info); |
40 | } else { | 40 | } else { |
41 | html("<tr><td>"); | 41 | html("<tr><td>"); |
42 | html_txt(buf); | 42 | html_txt(buf); |
43 | html("</td><td colspan='3'>"); | 43 | html("</td><td colspan='3'>"); |
44 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 44 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
45 | html("</td></tr>\n"); | 45 | html("</td></tr>\n"); |
46 | } | 46 | } |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | 50 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, |
51 | int flags, void *cb_data) | 51 | int flags, void *cb_data) |
52 | { | 52 | { |
53 | struct tag *tag; | 53 | struct tag *tag; |
54 | struct taginfo *info; | 54 | struct taginfo *info; |
55 | char buf[256], *page, *url; | 55 | char buf[256], *page, *url; |
56 | 56 | ||
57 | strncpy(buf, refname, sizeof(buf)); | 57 | strncpy(buf, refname, sizeof(buf)); |
58 | tag = lookup_tag(sha1); | 58 | tag = lookup_tag(sha1); |
59 | if (tag && !parse_tag(tag) && (info = cgit_parse_tag(tag))){ | 59 | if (tag && !parse_tag(tag) && (info = cgit_parse_tag(tag))){ |
60 | html("<tr><td>"); | 60 | html("<tr><td>"); |
61 | url = cgit_pageurl(cgit_query_repo, "view", | 61 | url = cgit_pageurl(cgit_query_repo, "view", |
62 | fmt("id=%s", sha1_to_hex(sha1))); | 62 | fmt("id=%s", sha1_to_hex(sha1))); |
63 | html_link_open(url, NULL, NULL); | 63 | html_link_open(url, NULL, NULL); |
64 | html_txt(buf); | 64 | html_txt(buf); |
65 | html_link_close(); | 65 | html_link_close(); |
66 | html("</td><td>"); | 66 | html("</td><td>"); |
67 | if (info->tagger_date > 0) | 67 | if (info->tagger_date > 0) |
68 | cgit_print_date(info->tagger_date); | 68 | cgit_print_date(info->tagger_date); |
69 | html("</td><td>"); | 69 | html("</td><td>"); |
70 | if (info->tagger) | 70 | if (info->tagger) |
71 | html(info->tagger); | 71 | html(info->tagger); |
72 | html("</td><td>"); | 72 | html("</td><td>"); |
73 | if (tag->tagged->type == OBJ_COMMIT) | 73 | if (tag->tagged->type == OBJ_COMMIT) |
74 | page = "commit"; | 74 | page = "commit"; |
75 | else if (tag->tagged->type == OBJ_TREE) | 75 | else if (tag->tagged->type == OBJ_TREE) |
76 | page = "tree"; | 76 | page = "tree"; |
77 | else | 77 | else |
78 | page = "view"; | 78 | page = "view"; |
79 | 79 | ||
80 | url = cgit_pageurl(cgit_query_repo, page, | 80 | url = cgit_pageurl(cgit_query_repo, page, |
81 | fmt("id=%s", sha1_to_hex(tag->tagged->sha1))); | 81 | fmt("id=%s", sha1_to_hex(tag->tagged->sha1))); |
82 | html_link_open(url, NULL, NULL); | 82 | html_link_open(url, NULL, NULL); |
83 | htmlf("%s %s", type_names[tag->tagged->type], | 83 | htmlf("%s %s", type_names[tag->tagged->type], |
84 | sha1_to_hex(tag->tagged->sha1)); | 84 | sha1_to_hex(tag->tagged->sha1)); |