summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.h1
-rw-r--r--cgitrc5
-rw-r--r--shared.c3
-rw-r--r--ui-summary.c8
4 files changed, 16 insertions, 1 deletions
diff --git a/cgit.h b/cgit.h
index d6bcde2..2f3fca1 100644
--- a/cgit.h
+++ b/cgit.h
@@ -106,48 +106,49 @@ extern struct repoinfo *cgit_repo;
106extern int cgit_cmd; 106extern int cgit_cmd;
107 107
108extern char *cgit_root_title; 108extern char *cgit_root_title;
109extern char *cgit_css; 109extern char *cgit_css;
110extern char *cgit_logo; 110extern char *cgit_logo;
111extern char *cgit_index_header; 111extern char *cgit_index_header;
112extern char *cgit_logo_link; 112extern char *cgit_logo_link;
113extern char *cgit_module_link; 113extern char *cgit_module_link;
114extern char *cgit_agefile; 114extern char *cgit_agefile;
115extern char *cgit_virtual_root; 115extern char *cgit_virtual_root;
116extern char *cgit_script_name; 116extern char *cgit_script_name;
117extern char *cgit_cache_root; 117extern char *cgit_cache_root;
118extern char *cgit_repo_group; 118extern char *cgit_repo_group;
119 119
120extern int cgit_nocache; 120extern int cgit_nocache;
121extern int cgit_snapshots; 121extern int cgit_snapshots;
122extern int cgit_enable_log_filecount; 122extern int cgit_enable_log_filecount;
123extern int cgit_enable_log_linecount; 123extern int cgit_enable_log_linecount;
124extern int cgit_max_lock_attempts; 124extern int cgit_max_lock_attempts;
125extern int cgit_cache_root_ttl; 125extern int cgit_cache_root_ttl;
126extern int cgit_cache_repo_ttl; 126extern int cgit_cache_repo_ttl;
127extern int cgit_cache_dynamic_ttl; 127extern int cgit_cache_dynamic_ttl;
128extern int cgit_cache_static_ttl; 128extern int cgit_cache_static_ttl;
129extern int cgit_cache_max_create_time; 129extern int cgit_cache_max_create_time;
130extern int cgit_summary_log;
130 131
131extern int cgit_max_msg_len; 132extern int cgit_max_msg_len;
132extern int cgit_max_repodesc_len; 133extern int cgit_max_repodesc_len;
133extern int cgit_max_commit_count; 134extern int cgit_max_commit_count;
134 135
135extern int cgit_query_has_symref; 136extern int cgit_query_has_symref;
136extern int cgit_query_has_sha1; 137extern int cgit_query_has_sha1;
137 138
138extern char *cgit_querystring; 139extern char *cgit_querystring;
139extern char *cgit_query_repo; 140extern char *cgit_query_repo;
140extern char *cgit_query_page; 141extern char *cgit_query_page;
141extern char *cgit_query_search; 142extern char *cgit_query_search;
142extern char *cgit_query_head; 143extern char *cgit_query_head;
143extern char *cgit_query_sha1; 144extern char *cgit_query_sha1;
144extern char *cgit_query_sha2; 145extern char *cgit_query_sha2;
145extern char *cgit_query_path; 146extern char *cgit_query_path;
146extern char *cgit_query_name; 147extern char *cgit_query_name;
147extern int cgit_query_ofs; 148extern int cgit_query_ofs;
148 149
149extern int htmlfd; 150extern int htmlfd;
150 151
151extern int cgit_get_cmd_index(const char *cmd); 152extern int cgit_get_cmd_index(const char *cmd);
152extern struct repoinfo *cgit_get_repoinfo(const char *url); 153extern struct repoinfo *cgit_get_repoinfo(const char *url);
153extern void cgit_global_config_cb(const char *name, const char *value); 154extern void cgit_global_config_cb(const char *name, const char *value);
diff --git a/cgitrc b/cgitrc
index 054a708..0f602e4 100644
--- a/cgitrc
+++ b/cgitrc
@@ -1,46 +1,51 @@
1## 1##
2## cgitrc: template for /etc/cgitrc 2## cgitrc: template for /etc/cgitrc
3## 3##
4 4
5 5
6## Uncomment and set to 1 to deactivate caching of generated pages. Mostly 6## Uncomment and set to 1 to deactivate caching of generated pages. Mostly
7## usefull for testing. 7## usefull for testing.
8#nocache=0 8#nocache=0
9 9
10 10
11## Enable/disable snapshots by default. This can be overridden per repo 11## Enable/disable snapshots by default. This can be overridden per repo
12#snapshots=0 12#snapshots=0
13 13
14 14
15## Enable/disable display of 'number of files changed' in log view 15## Enable/disable display of 'number of files changed' in log view
16#enable-log-filecount=0 16#enable-log-filecount=0
17 17
18 18
19## Enable/disable display of 'number of lines changed' in log view 19## Enable/disable display of 'number of lines changed' in log view
20#enable-log-linecount=0 20#enable-log-linecount=0
21 21
22 22
23## Enable/disable display of HEAD shortlog in summary view. Set it to maximum
24## number of commits that should be displayed
25#summary-log=0
26
27
23## Specify a root for virtual urls. This makes cgit generate urls like 28## Specify a root for virtual urls. This makes cgit generate urls like
24## 29##
25## http://localhost/git/repo/log/?id=master 30## http://localhost/git/repo/log/?id=master
26## 31##
27## instead of 32## instead of
28## 33##
29## http://localhost/cgit/cgit.cgi?r=repo&p=log&id=master 34## http://localhost/cgit/cgit.cgi?r=repo&p=log&id=master
30## 35##
31## For this to work with apache, rewrite rules must be added to httpd.conf, 36## For this to work with apache, rewrite rules must be added to httpd.conf,
32## possibly looking something like this: 37## possibly looking something like this:
33## 38##
34## RewriteRule ^/git/$ /cgit/cgit.cgi [L,QSA] 39## RewriteRule ^/git/$ /cgit/cgit.cgi [L,QSA]
35## RewriteRule ^/git/([^/]+)/$ /cgit/cgit.cgi?r=$1 [L,QSA] 40## RewriteRule ^/git/([^/]+)/$ /cgit/cgit.cgi?r=$1 [L,QSA]
36## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit/cgit.cgi?r=$1&p=$2 [L,QSA] 41## RewriteRule ^/git/([^/]+)/([^/]+)/$ /cgit/cgit.cgi?r=$1&p=$2 [L,QSA]
37## 42##
38## This setting is disabled by default. 43## This setting is disabled by default.
39#virtual-root=/git 44#virtual-root=/git
40 45
41 46
42## Set the title printed on the root page 47## Set the title printed on the root page
43#root-title=Git repository browser 48#root-title=Git repository browser
44 49
45 50
46## Link to css file 51## Link to css file
diff --git a/shared.c b/shared.c
index e3123a8..b6d2fa1 100644
--- a/shared.c
+++ b/shared.c
@@ -13,48 +13,49 @@ struct repoinfo *cgit_repo;
13int cgit_cmd; 13int cgit_cmd;
14 14
15char *cgit_root_title = "Git repository browser"; 15char *cgit_root_title = "Git repository browser";
16char *cgit_css = "/cgit.css"; 16char *cgit_css = "/cgit.css";
17char *cgit_logo = "/git-logo.png"; 17char *cgit_logo = "/git-logo.png";
18char *cgit_index_header = NULL; 18char *cgit_index_header = NULL;
19char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; 19char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
20char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; 20char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
21char *cgit_agefile = "info/web/last-modified"; 21char *cgit_agefile = "info/web/last-modified";
22char *cgit_virtual_root = NULL; 22char *cgit_virtual_root = NULL;
23char *cgit_script_name = CGIT_SCRIPT_NAME; 23char *cgit_script_name = CGIT_SCRIPT_NAME;
24char *cgit_cache_root = "/var/cache/cgit"; 24char *cgit_cache_root = "/var/cache/cgit";
25char *cgit_repo_group = NULL; 25char *cgit_repo_group = NULL;
26 26
27int cgit_nocache = 0; 27int cgit_nocache = 0;
28int cgit_snapshots = 0; 28int cgit_snapshots = 0;
29int cgit_enable_log_filecount = 0; 29int cgit_enable_log_filecount = 0;
30int cgit_enable_log_linecount = 0; 30int cgit_enable_log_linecount = 0;
31int cgit_max_lock_attempts = 5; 31int cgit_max_lock_attempts = 5;
32int cgit_cache_root_ttl = 5; 32int cgit_cache_root_ttl = 5;
33int cgit_cache_repo_ttl = 5; 33int cgit_cache_repo_ttl = 5;
34int cgit_cache_dynamic_ttl = 5; 34int cgit_cache_dynamic_ttl = 5;
35int cgit_cache_static_ttl = -1; 35int cgit_cache_static_ttl = -1;
36int cgit_cache_max_create_time = 5; 36int cgit_cache_max_create_time = 5;
37int cgit_summary_log = 0;
37 38
38int cgit_max_msg_len = 60; 39int cgit_max_msg_len = 60;
39int cgit_max_repodesc_len = 60; 40int cgit_max_repodesc_len = 60;
40int cgit_max_commit_count = 50; 41int cgit_max_commit_count = 50;
41 42
42int cgit_query_has_symref = 0; 43int cgit_query_has_symref = 0;
43int cgit_query_has_sha1 = 0; 44int cgit_query_has_sha1 = 0;
44 45
45char *cgit_querystring = NULL; 46char *cgit_querystring = NULL;
46char *cgit_query_repo = NULL; 47char *cgit_query_repo = NULL;
47char *cgit_query_page = NULL; 48char *cgit_query_page = NULL;
48char *cgit_query_head = NULL; 49char *cgit_query_head = NULL;
49char *cgit_query_search = NULL; 50char *cgit_query_search = NULL;
50char *cgit_query_sha1 = NULL; 51char *cgit_query_sha1 = NULL;
51char *cgit_query_sha2 = NULL; 52char *cgit_query_sha2 = NULL;
52char *cgit_query_path = NULL; 53char *cgit_query_path = NULL;
53char *cgit_query_name = NULL; 54char *cgit_query_name = NULL;
54int cgit_query_ofs = 0; 55int cgit_query_ofs = 0;
55 56
56int htmlfd = 0; 57int htmlfd = 0;
57 58
58 59
59int cgit_get_cmd_index(const char *cmd) 60int cgit_get_cmd_index(const char *cmd)
60{ 61{
@@ -143,48 +144,50 @@ void cgit_global_config_cb(const char *name, const char *value)
143 else if (!strcmp(name, "nocache")) 144 else if (!strcmp(name, "nocache"))
144 cgit_nocache = atoi(value); 145 cgit_nocache = atoi(value);
145 else if (!strcmp(name, "snapshots")) 146 else if (!strcmp(name, "snapshots"))
146 cgit_snapshots = atoi(value); 147 cgit_snapshots = atoi(value);
147 else if (!strcmp(name, "enable-log-filecount")) 148 else if (!strcmp(name, "enable-log-filecount"))
148 cgit_enable_log_filecount = atoi(value); 149 cgit_enable_log_filecount = atoi(value);
149 else if (!strcmp(name, "enable-log-linecount")) 150 else if (!strcmp(name, "enable-log-linecount"))
150 cgit_enable_log_linecount = atoi(value); 151 cgit_enable_log_linecount = atoi(value);
151 else if (!strcmp(name, "cache-root")) 152 else if (!strcmp(name, "cache-root"))
152 cgit_cache_root = xstrdup(value); 153 cgit_cache_root = xstrdup(value);
153 else if (!strcmp(name, "cache-root-ttl")) 154 else if (!strcmp(name, "cache-root-ttl"))
154 cgit_cache_root_ttl = atoi(value); 155 cgit_cache_root_ttl = atoi(value);
155 else if (!strcmp(name, "cache-repo-ttl")) 156 else if (!strcmp(name, "cache-repo-ttl"))
156 cgit_cache_repo_ttl = atoi(value); 157 cgit_cache_repo_ttl = atoi(value);
157 else if (!strcmp(name, "cache-static-ttl")) 158 else if (!strcmp(name, "cache-static-ttl"))
158 cgit_cache_static_ttl = atoi(value); 159 cgit_cache_static_ttl = atoi(value);
159 else if (!strcmp(name, "cache-dynamic-ttl")) 160 else if (!strcmp(name, "cache-dynamic-ttl"))
160 cgit_cache_dynamic_ttl = atoi(value); 161 cgit_cache_dynamic_ttl = atoi(value);
161 else if (!strcmp(name, "max-message-length")) 162 else if (!strcmp(name, "max-message-length"))
162 cgit_max_msg_len = atoi(value); 163 cgit_max_msg_len = atoi(value);
163 else if (!strcmp(name, "max-repodesc-length")) 164 else if (!strcmp(name, "max-repodesc-length"))
164 cgit_max_repodesc_len = atoi(value); 165 cgit_max_repodesc_len = atoi(value);
165 else if (!strcmp(name, "max-commit-count")) 166 else if (!strcmp(name, "max-commit-count"))
166 cgit_max_commit_count = atoi(value); 167 cgit_max_commit_count = atoi(value);
168 else if (!strcmp(name, "summary-log"))
169 cgit_summary_log = atoi(value);
167 else if (!strcmp(name, "agefile")) 170 else if (!strcmp(name, "agefile"))
168 cgit_agefile = xstrdup(value); 171 cgit_agefile = xstrdup(value);
169 else if (!strcmp(name, "repo.group")) 172 else if (!strcmp(name, "repo.group"))
170 cgit_repo_group = xstrdup(value); 173 cgit_repo_group = xstrdup(value);
171 else if (!strcmp(name, "repo.url")) 174 else if (!strcmp(name, "repo.url"))
172 cgit_repo = add_repo(value); 175 cgit_repo = add_repo(value);
173 else if (!strcmp(name, "repo.name")) 176 else if (!strcmp(name, "repo.name"))
174 cgit_repo->name = xstrdup(value); 177 cgit_repo->name = xstrdup(value);
175 else if (cgit_repo && !strcmp(name, "repo.path")) 178 else if (cgit_repo && !strcmp(name, "repo.path"))
176 cgit_repo->path = xstrdup(value); 179 cgit_repo->path = xstrdup(value);
177 else if (cgit_repo && !strcmp(name, "repo.desc")) 180 else if (cgit_repo && !strcmp(name, "repo.desc"))
178 cgit_repo->desc = xstrdup(value); 181 cgit_repo->desc = xstrdup(value);
179 else if (cgit_repo && !strcmp(name, "repo.owner")) 182 else if (cgit_repo && !strcmp(name, "repo.owner"))
180 cgit_repo->owner = xstrdup(value); 183 cgit_repo->owner = xstrdup(value);
181 else if (cgit_repo && !strcmp(name, "repo.defbranch")) 184 else if (cgit_repo && !strcmp(name, "repo.defbranch"))
182 cgit_repo->defbranch = xstrdup(value); 185 cgit_repo->defbranch = xstrdup(value);
183 else if (cgit_repo && !strcmp(name, "repo.snapshots")) 186 else if (cgit_repo && !strcmp(name, "repo.snapshots"))
184 cgit_repo->snapshots = cgit_snapshots * atoi(value); 187 cgit_repo->snapshots = cgit_snapshots * atoi(value);
185 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) 188 else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount"))
186 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); 189 cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value);
187 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) 190 else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount"))
188 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); 191 cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value);
189 else if (cgit_repo && !strcmp(name, "repo.module-link")) 192 else if (cgit_repo && !strcmp(name, "repo.module-link"))
190 cgit_repo->module_link= xstrdup(value); 193 cgit_repo->module_link= xstrdup(value);
diff --git a/ui-summary.c b/ui-summary.c
index 15e8aec..4bda4c2 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -1,45 +1,48 @@
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
11static int header; 11static int header;
12 12
13static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, 13static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
14 int flags, void *cb_data) 14 int flags, void *cb_data)
15{ 15{
16 struct commit *commit; 16 struct commit *commit;
17 struct commitinfo *info; 17 struct commitinfo *info;
18 char buf[256], *url; 18 char buf[256], *url;
19 19
20 strncpy(buf, refname, sizeof(buf)); 20 strncpy(buf, refname, sizeof(buf));
21 commit = lookup_commit(sha1); 21 commit = lookup_commit(sha1);
22 // object is not really parsed at this point, because of some fallout
23 // from previous calls to git functions in cgit_print_log()
24 commit->object.parsed = 0;
22 if (commit && !parse_commit(commit)){ 25 if (commit && !parse_commit(commit)){
23 info = cgit_parse_commit(commit); 26 info = cgit_parse_commit(commit);
24 html("<tr><td>"); 27 html("<tr><td>");
25 url = cgit_pageurl(cgit_query_repo, "log", 28 url = cgit_pageurl(cgit_query_repo, "log",
26 fmt("h=%s", refname)); 29 fmt("h=%s", refname));
27 html_link_open(url, NULL, NULL); 30 html_link_open(url, NULL, NULL);
28 html_txt(buf); 31 html_txt(buf);
29 html_link_close(); 32 html_link_close();
30 html("</td><td>"); 33 html("</td><td>");
31 cgit_print_age(commit->date, -1, NULL); 34 cgit_print_age(commit->date, -1, NULL);
32 html("</td><td>"); 35 html("</td><td>");
33 html_txt(info->author); 36 html_txt(info->author);
34 html("</td><td>"); 37 html("</td><td>");
35 url = cgit_pageurl(cgit_query_repo, "commit", 38 url = cgit_pageurl(cgit_query_repo, "commit",
36 fmt("h=%s", sha1_to_hex(sha1))); 39 fmt("h=%s", sha1_to_hex(sha1)));
37 html_link_open(url, NULL, NULL); 40 html_link_open(url, NULL, NULL);
38 html_ntxt(cgit_max_msg_len, info->subject); 41 html_ntxt(cgit_max_msg_len, info->subject);
39 html_link_close(); 42 html_link_close();
40 html("</td></tr>\n"); 43 html("</td></tr>\n");
41 cgit_free_commitinfo(info); 44 cgit_free_commitinfo(info);
42 } else { 45 } else {
43 html("<tr><td>"); 46 html("<tr><td>");
44 html_txt(buf); 47 html_txt(buf);
45 html("</td><td colspan='3'>"); 48 html("</td><td colspan='3'>");
@@ -182,31 +185,34 @@ static void cgit_print_tags()
182 header = 0; 185 header = 0;
183 for_each_tag_ref(cgit_print_tag_cb, NULL); 186 for_each_tag_ref(cgit_print_tag_cb, NULL);
184} 187}
185 188
186static void cgit_print_archives() 189static void cgit_print_archives()
187{ 190{
188 header = 0; 191 header = 0;
189 for_each_ref(cgit_print_archive_cb, NULL); 192 for_each_ref(cgit_print_archive_cb, NULL);
190 if (header) 193 if (header)
191 html("</table>"); 194 html("</table>");
192} 195}
193 196
194void cgit_print_summary() 197void cgit_print_summary()
195{ 198{
196 html("<div id='summary'>"); 199 html("<div id='summary'>");
197 cgit_print_archives(); 200 cgit_print_archives();
198 html("<h2>"); 201 html("<h2>");
199 html_txt(cgit_repo->name); 202 html_txt(cgit_repo->name);
200 html(" - "); 203 html(" - ");
201 html_txt(cgit_repo->desc); 204 html_txt(cgit_repo->desc);
202 html("</h2>"); 205 html("</h2>");
203 if (cgit_repo->readme) 206 if (cgit_repo->readme)
204 html_include(cgit_repo->readme); 207 html_include(cgit_repo->readme);
205 html("</div>"); 208 html("</div>");
206 209 if (cgit_summary_log > 0)
210 cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, 0);
207 html("<table class='list nowrap'>"); 211 html("<table class='list nowrap'>");
212 if (cgit_summary_log > 0)
213 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
208 cgit_print_branches(); 214 cgit_print_branches();
209 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 215 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
210 cgit_print_tags(); 216 cgit_print_tags();
211 html("</table>"); 217 html("</table>");
212} 218}