summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h1
2 files changed, 1 insertions, 2 deletions
diff --git a/cgit.c b/cgit.c
index 3943a0f..f749b6b 100644
--- a/cgit.c
+++ b/cgit.c
@@ -1,455 +1,455 @@
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 "cmd.h" 10#include "cmd.h"
11#include "ui-shared.h" 11#include "ui-shared.h"
12 12
13const char *cgit_version = CGIT_VERSION; 13const char *cgit_version = CGIT_VERSION;
14 14
15void config_cb(const char *name, const char *value) 15void config_cb(const char *name, const char *value)
16{ 16{
17 if (!strcmp(name, "root-title")) 17 if (!strcmp(name, "root-title"))
18 ctx.cfg.root_title = xstrdup(value); 18 ctx.cfg.root_title = xstrdup(value);
19 else if (!strcmp(name, "css")) 19 else if (!strcmp(name, "css"))
20 ctx.cfg.css = xstrdup(value); 20 ctx.cfg.css = xstrdup(value);
21 else if (!strcmp(name, "logo")) 21 else if (!strcmp(name, "logo"))
22 ctx.cfg.logo = xstrdup(value); 22 ctx.cfg.logo = xstrdup(value);
23 else if (!strcmp(name, "index-header")) 23 else if (!strcmp(name, "index-header"))
24 ctx.cfg.index_header = xstrdup(value); 24 ctx.cfg.index_header = xstrdup(value);
25 else if (!strcmp(name, "index-info")) 25 else if (!strcmp(name, "index-info"))
26 ctx.cfg.index_info = xstrdup(value); 26 ctx.cfg.index_info = xstrdup(value);
27 else if (!strcmp(name, "logo-link")) 27 else if (!strcmp(name, "logo-link"))
28 ctx.cfg.logo_link = xstrdup(value); 28 ctx.cfg.logo_link = xstrdup(value);
29 else if (!strcmp(name, "module-link")) 29 else if (!strcmp(name, "module-link"))
30 ctx.cfg.module_link = xstrdup(value); 30 ctx.cfg.module_link = xstrdup(value);
31 else if (!strcmp(name, "virtual-root")) { 31 else if (!strcmp(name, "virtual-root")) {
32 ctx.cfg.virtual_root = trim_end(value, '/'); 32 ctx.cfg.virtual_root = trim_end(value, '/');
33 if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) 33 if (!ctx.cfg.virtual_root && (!strcmp(value, "/")))
34 ctx.cfg.virtual_root = ""; 34 ctx.cfg.virtual_root = "";
35 } else if (!strcmp(name, "nocache")) 35 } else if (!strcmp(name, "nocache"))
36 ctx.cfg.nocache = atoi(value); 36 ctx.cfg.nocache = atoi(value);
37 else if (!strcmp(name, "snapshots")) 37 else if (!strcmp(name, "snapshots"))
38 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); 38 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
39 else if (!strcmp(name, "enable-index-links")) 39 else if (!strcmp(name, "enable-index-links"))
40 ctx.cfg.enable_index_links = atoi(value); 40 ctx.cfg.enable_index_links = atoi(value);
41 else if (!strcmp(name, "enable-log-filecount")) 41 else if (!strcmp(name, "enable-log-filecount"))
42 ctx.cfg.enable_log_filecount = atoi(value); 42 ctx.cfg.enable_log_filecount = atoi(value);
43 else if (!strcmp(name, "enable-log-linecount")) 43 else if (!strcmp(name, "enable-log-linecount"))
44 ctx.cfg.enable_log_linecount = atoi(value); 44 ctx.cfg.enable_log_linecount = atoi(value);
45 else if (!strcmp(name, "cache-root")) 45 else if (!strcmp(name, "cache-root"))
46 ctx.cfg.cache_root = xstrdup(value); 46 ctx.cfg.cache_root = xstrdup(value);
47 else if (!strcmp(name, "cache-root-ttl")) 47 else if (!strcmp(name, "cache-root-ttl"))
48 ctx.cfg.cache_root_ttl = atoi(value); 48 ctx.cfg.cache_root_ttl = atoi(value);
49 else if (!strcmp(name, "cache-repo-ttl")) 49 else if (!strcmp(name, "cache-repo-ttl"))
50 ctx.cfg.cache_repo_ttl = atoi(value); 50 ctx.cfg.cache_repo_ttl = atoi(value);
51 else if (!strcmp(name, "cache-static-ttl")) 51 else if (!strcmp(name, "cache-static-ttl"))
52 ctx.cfg.cache_static_ttl = atoi(value); 52 ctx.cfg.cache_static_ttl = atoi(value);
53 else if (!strcmp(name, "cache-dynamic-ttl")) 53 else if (!strcmp(name, "cache-dynamic-ttl"))
54 ctx.cfg.cache_dynamic_ttl = atoi(value); 54 ctx.cfg.cache_dynamic_ttl = atoi(value);
55 else if (!strcmp(name, "max-message-length")) 55 else if (!strcmp(name, "max-message-length"))
56 ctx.cfg.max_msg_len = atoi(value); 56 ctx.cfg.max_msg_len = atoi(value);
57 else if (!strcmp(name, "max-repodesc-length")) 57 else if (!strcmp(name, "max-repodesc-length"))
58 ctx.cfg.max_repodesc_len = atoi(value); 58 ctx.cfg.max_repodesc_len = atoi(value);
59 else if (!strcmp(name, "max-commit-count")) 59 else if (!strcmp(name, "max-commit-count"))
60 ctx.cfg.max_commit_count = atoi(value); 60 ctx.cfg.max_commit_count = atoi(value);
61 else if (!strcmp(name, "summary-log")) 61 else if (!strcmp(name, "summary-log"))
62 ctx.cfg.summary_log = atoi(value); 62 ctx.cfg.summary_log = atoi(value);
63 else if (!strcmp(name, "summary-branches")) 63 else if (!strcmp(name, "summary-branches"))
64 ctx.cfg.summary_branches = atoi(value); 64 ctx.cfg.summary_branches = atoi(value);
65 else if (!strcmp(name, "summary-tags")) 65 else if (!strcmp(name, "summary-tags"))
66 ctx.cfg.summary_tags = atoi(value); 66 ctx.cfg.summary_tags = atoi(value);
67 else if (!strcmp(name, "agefile")) 67 else if (!strcmp(name, "agefile"))
68 ctx.cfg.agefile = xstrdup(value); 68 ctx.cfg.agefile = xstrdup(value);
69 else if (!strcmp(name, "renamelimit")) 69 else if (!strcmp(name, "renamelimit"))
70 ctx.cfg.renamelimit = atoi(value); 70 ctx.cfg.renamelimit = atoi(value);
71 else if (!strcmp(name, "robots")) 71 else if (!strcmp(name, "robots"))
72 ctx.cfg.robots = xstrdup(value); 72 ctx.cfg.robots = xstrdup(value);
73 else if (!strcmp(name, "clone-prefix")) 73 else if (!strcmp(name, "clone-prefix"))
74 ctx.cfg.clone_prefix = xstrdup(value); 74 ctx.cfg.clone_prefix = xstrdup(value);
75 else if (!strcmp(name, "repo.group")) 75 else if (!strcmp(name, "repo.group"))
76 ctx.cfg.repo_group = xstrdup(value); 76 ctx.cfg.repo_group = xstrdup(value);
77 else if (!strcmp(name, "repo.url")) 77 else if (!strcmp(name, "repo.url"))
78 ctx.repo = cgit_add_repo(value); 78 ctx.repo = cgit_add_repo(value);
79 else if (!strcmp(name, "repo.name")) 79 else if (!strcmp(name, "repo.name"))
80 ctx.repo->name = xstrdup(value); 80 ctx.repo->name = xstrdup(value);
81 else if (ctx.repo && !strcmp(name, "repo.path")) 81 else if (ctx.repo && !strcmp(name, "repo.path"))
82 ctx.repo->path = trim_end(value, '/'); 82 ctx.repo->path = trim_end(value, '/');
83 else if (ctx.repo && !strcmp(name, "repo.clone-url")) 83 else if (ctx.repo && !strcmp(name, "repo.clone-url"))
84 ctx.repo->clone_url = xstrdup(value); 84 ctx.repo->clone_url = xstrdup(value);
85 else if (ctx.repo && !strcmp(name, "repo.desc")) 85 else if (ctx.repo && !strcmp(name, "repo.desc"))
86 ctx.repo->desc = xstrdup(value); 86 ctx.repo->desc = xstrdup(value);
87 else if (ctx.repo && !strcmp(name, "repo.owner")) 87 else if (ctx.repo && !strcmp(name, "repo.owner"))
88 ctx.repo->owner = xstrdup(value); 88 ctx.repo->owner = xstrdup(value);
89 else if (ctx.repo && !strcmp(name, "repo.defbranch")) 89 else if (ctx.repo && !strcmp(name, "repo.defbranch"))
90 ctx.repo->defbranch = xstrdup(value); 90 ctx.repo->defbranch = xstrdup(value);
91 else if (ctx.repo && !strcmp(name, "repo.snapshots")) 91 else if (ctx.repo && !strcmp(name, "repo.snapshots"))
92 ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ 92 ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
93 else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) 93 else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount"))
94 ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); 94 ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
95 else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) 95 else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount"))
96 ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); 96 ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value);
97 else if (ctx.repo && !strcmp(name, "repo.module-link")) 97 else if (ctx.repo && !strcmp(name, "repo.module-link"))
98 ctx.repo->module_link= xstrdup(value); 98 ctx.repo->module_link= xstrdup(value);
99 else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { 99 else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) {
100 if (*value == '/') 100 if (*value == '/')
101 ctx.repo->readme = xstrdup(value); 101 ctx.repo->readme = xstrdup(value);
102 else 102 else
103 ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); 103 ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
104 } else if (!strcmp(name, "include")) 104 } else if (!strcmp(name, "include"))
105 cgit_read_config(value, config_cb); 105 cgit_read_config(value, config_cb);
106} 106}
107 107
108static void querystring_cb(const char *name, const char *value) 108static void querystring_cb(const char *name, const char *value)
109{ 109{
110 if (!strcmp(name,"r")) { 110 if (!strcmp(name,"r")) {
111 ctx.qry.repo = xstrdup(value); 111 ctx.qry.repo = xstrdup(value);
112 ctx.repo = cgit_get_repoinfo(value); 112 ctx.repo = cgit_get_repoinfo(value);
113 } else if (!strcmp(name, "p")) { 113 } else if (!strcmp(name, "p")) {
114 ctx.qry.page = xstrdup(value); 114 ctx.qry.page = xstrdup(value);
115 } else if (!strcmp(name, "url")) { 115 } else if (!strcmp(name, "url")) {
116 cgit_parse_url(value); 116 cgit_parse_url(value);
117 } else if (!strcmp(name, "qt")) { 117 } else if (!strcmp(name, "qt")) {
118 ctx.qry.grep = xstrdup(value); 118 ctx.qry.grep = xstrdup(value);
119 } else if (!strcmp(name, "q")) { 119 } else if (!strcmp(name, "q")) {
120 ctx.qry.search = xstrdup(value); 120 ctx.qry.search = xstrdup(value);
121 } else if (!strcmp(name, "h")) { 121 } else if (!strcmp(name, "h")) {
122 ctx.qry.head = xstrdup(value); 122 ctx.qry.head = xstrdup(value);
123 ctx.qry.has_symref = 1; 123 ctx.qry.has_symref = 1;
124 } else if (!strcmp(name, "id")) { 124 } else if (!strcmp(name, "id")) {
125 ctx.qry.sha1 = xstrdup(value); 125 ctx.qry.sha1 = xstrdup(value);
126 ctx.qry.has_sha1 = 1; 126 ctx.qry.has_sha1 = 1;
127 } else if (!strcmp(name, "id2")) { 127 } else if (!strcmp(name, "id2")) {
128 ctx.qry.sha2 = xstrdup(value); 128 ctx.qry.sha2 = xstrdup(value);
129 ctx.qry.has_sha1 = 1; 129 ctx.qry.has_sha1 = 1;
130 } else if (!strcmp(name, "ofs")) { 130 } else if (!strcmp(name, "ofs")) {
131 ctx.qry.ofs = atoi(value); 131 ctx.qry.ofs = atoi(value);
132 } else if (!strcmp(name, "path")) { 132 } else if (!strcmp(name, "path")) {
133 ctx.qry.path = trim_end(value, '/'); 133 ctx.qry.path = trim_end(value, '/');
134 } else if (!strcmp(name, "name")) { 134 } else if (!strcmp(name, "name")) {
135 ctx.qry.name = xstrdup(value); 135 ctx.qry.name = xstrdup(value);
136 } 136 }
137} 137}
138 138
139static void prepare_context(struct cgit_context *ctx) 139static void prepare_context(struct cgit_context *ctx)
140{ 140{
141 memset(ctx, 0, sizeof(ctx)); 141 memset(ctx, 0, sizeof(ctx));
142 ctx->cfg.agefile = "info/web/last-modified"; 142 ctx->cfg.agefile = "info/web/last-modified";
143 ctx->cfg.cache_dynamic_ttl = 5; 143 ctx->cfg.cache_dynamic_ttl = 5;
144 ctx->cfg.cache_max_create_time = 5; 144 ctx->cfg.cache_max_create_time = 5;
145 ctx->cfg.cache_repo_ttl = 5; 145 ctx->cfg.cache_repo_ttl = 5;
146 ctx->cfg.cache_root = CGIT_CACHE_ROOT; 146 ctx->cfg.cache_root = CGIT_CACHE_ROOT;
147 ctx->cfg.cache_root_ttl = 5; 147 ctx->cfg.cache_root_ttl = 5;
148 ctx->cfg.cache_static_ttl = -1; 148 ctx->cfg.cache_static_ttl = -1;
149 ctx->cfg.css = "/cgit.css"; 149 ctx->cfg.css = "/cgit.css";
150 ctx->cfg.logo = "/git-logo.png"; 150 ctx->cfg.logo = "/git-logo.png";
151 ctx->cfg.max_commit_count = 50; 151 ctx->cfg.max_commit_count = 50;
152 ctx->cfg.max_lock_attempts = 5; 152 ctx->cfg.max_lock_attempts = 5;
153 ctx->cfg.max_msg_len = 60; 153 ctx->cfg.max_msg_len = 60;
154 ctx->cfg.max_repodesc_len = 60; 154 ctx->cfg.max_repodesc_len = 60;
155 ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; 155 ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
156 ctx->cfg.renamelimit = -1; 156 ctx->cfg.renamelimit = -1;
157 ctx->cfg.robots = "index, nofollow"; 157 ctx->cfg.robots = "index, nofollow";
158 ctx->cfg.root_title = "Git repository browser"; 158 ctx->cfg.root_title = "Git repository browser";
159 ctx->cfg.script_name = CGIT_SCRIPT_NAME; 159 ctx->cfg.script_name = CGIT_SCRIPT_NAME;
160 ctx->page.mimetype = "text/html"; 160 ctx->page.mimetype = "text/html";
161 ctx->page.charset = PAGE_ENCODING; 161 ctx->page.charset = PAGE_ENCODING;
162 ctx->page.filename = NULL; 162 ctx->page.filename = NULL;
163} 163}
164 164
165static int cgit_prepare_cache(struct cacheitem *item) 165static int cgit_prepare_cache(struct cacheitem *item)
166{ 166{
167 if (!ctx.repo && ctx.qry.repo) { 167 if (!ctx.repo && ctx.qry.repo) {
168 ctx.page.title = fmt("%s - %s", ctx.cfg.root_title, 168 ctx.page.title = fmt("%s - %s", ctx.cfg.root_title,
169 "Bad request"); 169 "Bad request");
170 cgit_print_http_headers(&ctx); 170 cgit_print_http_headers(&ctx);
171 cgit_print_docstart(&ctx); 171 cgit_print_docstart(&ctx);
172 cgit_print_pageheader(&ctx); 172 cgit_print_pageheader(&ctx);
173 cgit_print_error(fmt("Unknown repo: %s", ctx.qry.repo)); 173 cgit_print_error(fmt("Unknown repo: %s", ctx.qry.repo));
174 cgit_print_docend(); 174 cgit_print_docend();
175 return 0; 175 return 0;
176 } 176 }
177 177
178 if (!ctx.repo) { 178 if (!ctx.repo) {
179 item->name = xstrdup(fmt("%s/index.html", ctx.cfg.cache_root)); 179 item->name = xstrdup(fmt("%s/index.html", ctx.cfg.cache_root));
180 item->ttl = ctx.cfg.cache_root_ttl; 180 item->ttl = ctx.cfg.cache_root_ttl;
181 return 1; 181 return 1;
182 } 182 }
183 183
184 if (!cgit_cmd) { 184 if (!ctx.qry.page) {
185 item->name = xstrdup(fmt("%s/%s/index.%s.html", ctx.cfg.cache_root, 185 item->name = xstrdup(fmt("%s/%s/index.%s.html", ctx.cfg.cache_root,
186 cache_safe_filename(ctx.repo->url), 186 cache_safe_filename(ctx.repo->url),
187 cache_safe_filename(ctx.qry.raw))); 187 cache_safe_filename(ctx.qry.raw)));
188 item->ttl = ctx.cfg.cache_repo_ttl; 188 item->ttl = ctx.cfg.cache_repo_ttl;
189 } else { 189 } else {
190 item->name = xstrdup(fmt("%s/%s/%s/%s.html", ctx.cfg.cache_root, 190 item->name = xstrdup(fmt("%s/%s/%s/%s.html", ctx.cfg.cache_root,
191 cache_safe_filename(ctx.repo->url), 191 cache_safe_filename(ctx.repo->url),
192 ctx.qry.page, 192 ctx.qry.page,
193 cache_safe_filename(ctx.qry.raw))); 193 cache_safe_filename(ctx.qry.raw)));
194 if (ctx.qry.has_symref) 194 if (ctx.qry.has_symref)
195 item->ttl = ctx.cfg.cache_dynamic_ttl; 195 item->ttl = ctx.cfg.cache_dynamic_ttl;
196 else if (ctx.qry.has_sha1) 196 else if (ctx.qry.has_sha1)
197 item->ttl = ctx.cfg.cache_static_ttl; 197 item->ttl = ctx.cfg.cache_static_ttl;
198 else 198 else
199 item->ttl = ctx.cfg.cache_repo_ttl; 199 item->ttl = ctx.cfg.cache_repo_ttl;
200 } 200 }
201 return 1; 201 return 1;
202} 202}
203 203
204struct refmatch { 204struct refmatch {
205 char *req_ref; 205 char *req_ref;
206 char *first_ref; 206 char *first_ref;
207 int match; 207 int match;
208}; 208};
209 209
210int find_current_ref(const char *refname, const unsigned char *sha1, 210int find_current_ref(const char *refname, const unsigned char *sha1,
211 int flags, void *cb_data) 211 int flags, void *cb_data)
212{ 212{
213 struct refmatch *info; 213 struct refmatch *info;
214 214
215 info = (struct refmatch *)cb_data; 215 info = (struct refmatch *)cb_data;
216 if (!strcmp(refname, info->req_ref)) 216 if (!strcmp(refname, info->req_ref))
217 info->match = 1; 217 info->match = 1;
218 if (!info->first_ref) 218 if (!info->first_ref)
219 info->first_ref = xstrdup(refname); 219 info->first_ref = xstrdup(refname);
220 return info->match; 220 return info->match;
221} 221}
222 222
223char *find_default_branch(struct cgit_repo *repo) 223char *find_default_branch(struct cgit_repo *repo)
224{ 224{
225 struct refmatch info; 225 struct refmatch info;
226 226
227 info.req_ref = repo->defbranch; 227 info.req_ref = repo->defbranch;
228 info.first_ref = NULL; 228 info.first_ref = NULL;
229 info.match = 0; 229 info.match = 0;
230 for_each_branch_ref(find_current_ref, &info); 230 for_each_branch_ref(find_current_ref, &info);
231 if (info.match) 231 if (info.match)
232 return info.req_ref; 232 return info.req_ref;
233 else 233 else
234 return info.first_ref; 234 return info.first_ref;
235} 235}
236 236
237static int prepare_repo_cmd(struct cgit_context *ctx) 237static int prepare_repo_cmd(struct cgit_context *ctx)
238{ 238{
239 char *tmp; 239 char *tmp;
240 unsigned char sha1[20]; 240 unsigned char sha1[20];
241 int nongit = 0; 241 int nongit = 0;
242 242
243 setenv("GIT_DIR", ctx->repo->path, 1); 243 setenv("GIT_DIR", ctx->repo->path, 1);
244 setup_git_directory_gently(&nongit); 244 setup_git_directory_gently(&nongit);
245 if (nongit) { 245 if (nongit) {
246 ctx->page.title = fmt("%s - %s", ctx->cfg.root_title, 246 ctx->page.title = fmt("%s - %s", ctx->cfg.root_title,
247 "config error"); 247 "config error");
248 tmp = fmt("Not a git repository: '%s'", ctx->repo->path); 248 tmp = fmt("Not a git repository: '%s'", ctx->repo->path);
249 ctx->repo = NULL; 249 ctx->repo = NULL;
250 cgit_print_http_headers(ctx); 250 cgit_print_http_headers(ctx);
251 cgit_print_docstart(ctx); 251 cgit_print_docstart(ctx);
252 cgit_print_pageheader(ctx); 252 cgit_print_pageheader(ctx);
253 cgit_print_error(tmp); 253 cgit_print_error(tmp);
254 cgit_print_docend(); 254 cgit_print_docend();
255 return 1; 255 return 1;
256 } 256 }
257 ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc); 257 ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc);
258 258
259 if (!ctx->qry.head) { 259 if (!ctx->qry.head) {
260 ctx->qry.head = xstrdup(find_default_branch(ctx->repo)); 260 ctx->qry.head = xstrdup(find_default_branch(ctx->repo));
261 ctx->repo->defbranch = ctx->qry.head; 261 ctx->repo->defbranch = ctx->qry.head;
262 } 262 }
263 263
264 if (!ctx->qry.head) { 264 if (!ctx->qry.head) {
265 cgit_print_http_headers(ctx); 265 cgit_print_http_headers(ctx);
266 cgit_print_docstart(ctx); 266 cgit_print_docstart(ctx);
267 cgit_print_pageheader(ctx); 267 cgit_print_pageheader(ctx);
268 cgit_print_error("Repository seems to be empty"); 268 cgit_print_error("Repository seems to be empty");
269 cgit_print_docend(); 269 cgit_print_docend();
270 return 1; 270 return 1;
271 } 271 }
272 272
273 if (get_sha1(ctx->qry.head, sha1)) { 273 if (get_sha1(ctx->qry.head, sha1)) {
274 tmp = xstrdup(ctx->qry.head); 274 tmp = xstrdup(ctx->qry.head);
275 ctx->qry.head = ctx->repo->defbranch; 275 ctx->qry.head = ctx->repo->defbranch;
276 cgit_print_http_headers(ctx); 276 cgit_print_http_headers(ctx);
277 cgit_print_docstart(ctx); 277 cgit_print_docstart(ctx);
278 cgit_print_pageheader(ctx); 278 cgit_print_pageheader(ctx);
279 cgit_print_error(fmt("Invalid branch: %s", tmp)); 279 cgit_print_error(fmt("Invalid branch: %s", tmp));
280 cgit_print_docend(); 280 cgit_print_docend();
281 return 1; 281 return 1;
282 } 282 }
283 return 0; 283 return 0;
284} 284}
285 285
286static void process_request(struct cgit_context *ctx) 286static void process_request(struct cgit_context *ctx)
287{ 287{
288 struct cgit_cmd *cmd; 288 struct cgit_cmd *cmd;
289 289
290 cmd = cgit_get_cmd(ctx); 290 cmd = cgit_get_cmd(ctx);
291 if (!cmd) { 291 if (!cmd) {
292 ctx->page.title = "cgit error"; 292 ctx->page.title = "cgit error";
293 ctx->repo = NULL; 293 ctx->repo = NULL;
294 cgit_print_http_headers(ctx); 294 cgit_print_http_headers(ctx);
295 cgit_print_docstart(ctx); 295 cgit_print_docstart(ctx);
296 cgit_print_pageheader(ctx); 296 cgit_print_pageheader(ctx);
297 cgit_print_error("Invalid request"); 297 cgit_print_error("Invalid request");
298 cgit_print_docend(); 298 cgit_print_docend();
299 return; 299 return;
300 } 300 }
301 301
302 if (cmd->want_repo && prepare_repo_cmd(ctx)) 302 if (cmd->want_repo && prepare_repo_cmd(ctx))
303 return; 303 return;
304 304
305 if (cmd->want_layout) { 305 if (cmd->want_layout) {
306 cgit_print_http_headers(ctx); 306 cgit_print_http_headers(ctx);
307 cgit_print_docstart(ctx); 307 cgit_print_docstart(ctx);
308 cgit_print_pageheader(ctx); 308 cgit_print_pageheader(ctx);
309 } 309 }
310 310
311 cmd->fn(ctx); 311 cmd->fn(ctx);
312 312
313 if (cmd->want_layout) 313 if (cmd->want_layout)
314 cgit_print_docend(); 314 cgit_print_docend();
315} 315}
316 316
317static long ttl_seconds(long ttl) 317static long ttl_seconds(long ttl)
318{ 318{
319 if (ttl<0) 319 if (ttl<0)
320 return 60 * 60 * 24 * 365; 320 return 60 * 60 * 24 * 365;
321 else 321 else
322 return ttl * 60; 322 return ttl * 60;
323} 323}
324 324
325static void cgit_fill_cache(struct cacheitem *item, int use_cache) 325static void cgit_fill_cache(struct cacheitem *item, int use_cache)
326{ 326{
327 int stdout2; 327 int stdout2;
328 328
329 if (use_cache) { 329 if (use_cache) {
330 stdout2 = chk_positive(dup(STDOUT_FILENO), 330 stdout2 = chk_positive(dup(STDOUT_FILENO),
331 "Preserving STDOUT"); 331 "Preserving STDOUT");
332 chk_zero(close(STDOUT_FILENO), "Closing STDOUT"); 332 chk_zero(close(STDOUT_FILENO), "Closing STDOUT");
333 chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)"); 333 chk_positive(dup2(item->fd, STDOUT_FILENO), "Dup2(cachefile)");
334 } 334 }
335 335
336 ctx.page.modified = time(NULL); 336 ctx.page.modified = time(NULL);
337 ctx.page.expires = ctx.page.modified + ttl_seconds(item->ttl); 337 ctx.page.expires = ctx.page.modified + ttl_seconds(item->ttl);
338 process_request(&ctx); 338 process_request(&ctx);
339 339
340 if (use_cache) { 340 if (use_cache) {
341 chk_zero(close(STDOUT_FILENO), "Close redirected STDOUT"); 341 chk_zero(close(STDOUT_FILENO), "Close redirected STDOUT");
342 chk_positive(dup2(stdout2, STDOUT_FILENO), 342 chk_positive(dup2(stdout2, STDOUT_FILENO),
343 "Restoring original STDOUT"); 343 "Restoring original STDOUT");
344 chk_zero(close(stdout2), "Closing temporary STDOUT"); 344 chk_zero(close(stdout2), "Closing temporary STDOUT");
345 } 345 }
346} 346}
347 347
348static void cgit_check_cache(struct cacheitem *item) 348static void cgit_check_cache(struct cacheitem *item)
349{ 349{
350 int i = 0; 350 int i = 0;
351 351
352 top: 352 top:
353 if (++i > ctx.cfg.max_lock_attempts) { 353 if (++i > ctx.cfg.max_lock_attempts) {
354 die("cgit_refresh_cache: unable to lock %s: %s", 354 die("cgit_refresh_cache: unable to lock %s: %s",
355 item->name, strerror(errno)); 355 item->name, strerror(errno));
356 } 356 }
357 if (!cache_exist(item)) { 357 if (!cache_exist(item)) {
358 if (!cache_lock(item)) { 358 if (!cache_lock(item)) {
359 sleep(1); 359 sleep(1);
360 goto top; 360 goto top;
361 } 361 }
362 if (!cache_exist(item)) { 362 if (!cache_exist(item)) {
363 cgit_fill_cache(item, 1); 363 cgit_fill_cache(item, 1);
364 cache_unlock(item); 364 cache_unlock(item);
365 } else { 365 } else {
366 cache_cancel_lock(item); 366 cache_cancel_lock(item);
367 } 367 }
368 } else if (cache_expired(item) && cache_lock(item)) { 368 } else if (cache_expired(item) && cache_lock(item)) {
369 if (cache_expired(item)) { 369 if (cache_expired(item)) {
370 cgit_fill_cache(item, 1); 370 cgit_fill_cache(item, 1);
371 cache_unlock(item); 371 cache_unlock(item);
372 } else { 372 } else {
373 cache_cancel_lock(item); 373 cache_cancel_lock(item);
374 } 374 }
375 } 375 }
376} 376}
377 377
378static void cgit_print_cache(struct cacheitem *item) 378static void cgit_print_cache(struct cacheitem *item)
379{ 379{
380 static char buf[4096]; 380 static char buf[4096];
381 ssize_t i; 381 ssize_t i;
382 382
383 int fd = open(item->name, O_RDONLY); 383 int fd = open(item->name, O_RDONLY);
384 if (fd<0) 384 if (fd<0)
385 die("Unable to open cached file %s", item->name); 385 die("Unable to open cached file %s", item->name);
386 386
387 while((i=read(fd, buf, sizeof(buf))) > 0) 387 while((i=read(fd, buf, sizeof(buf))) > 0)
388 write(STDOUT_FILENO, buf, i); 388 write(STDOUT_FILENO, buf, i);
389 389
390 close(fd); 390 close(fd);
391} 391}
392 392
393static void cgit_parse_args(int argc, const char **argv) 393static void cgit_parse_args(int argc, const char **argv)
394{ 394{
395 int i; 395 int i;
396 396
397 for (i = 1; i < argc; i++) { 397 for (i = 1; i < argc; i++) {
398 if (!strncmp(argv[i], "--cache=", 8)) { 398 if (!strncmp(argv[i], "--cache=", 8)) {
399 ctx.cfg.cache_root = xstrdup(argv[i]+8); 399 ctx.cfg.cache_root = xstrdup(argv[i]+8);
400 } 400 }
401 if (!strcmp(argv[i], "--nocache")) { 401 if (!strcmp(argv[i], "--nocache")) {
402 ctx.cfg.nocache = 1; 402 ctx.cfg.nocache = 1;
403 } 403 }
404 if (!strncmp(argv[i], "--query=", 8)) { 404 if (!strncmp(argv[i], "--query=", 8)) {
405 ctx.qry.raw = xstrdup(argv[i]+8); 405 ctx.qry.raw = xstrdup(argv[i]+8);
406 } 406 }
407 if (!strncmp(argv[i], "--repo=", 7)) { 407 if (!strncmp(argv[i], "--repo=", 7)) {
408 ctx.qry.repo = xstrdup(argv[i]+7); 408 ctx.qry.repo = xstrdup(argv[i]+7);
409 } 409 }
410 if (!strncmp(argv[i], "--page=", 7)) { 410 if (!strncmp(argv[i], "--page=", 7)) {
411 ctx.qry.page = xstrdup(argv[i]+7); 411 ctx.qry.page = xstrdup(argv[i]+7);
412 } 412 }
413 if (!strncmp(argv[i], "--head=", 7)) { 413 if (!strncmp(argv[i], "--head=", 7)) {
414 ctx.qry.head = xstrdup(argv[i]+7); 414 ctx.qry.head = xstrdup(argv[i]+7);
415 ctx.qry.has_symref = 1; 415 ctx.qry.has_symref = 1;
416 } 416 }
417 if (!strncmp(argv[i], "--sha1=", 7)) { 417 if (!strncmp(argv[i], "--sha1=", 7)) {
418 ctx.qry.sha1 = xstrdup(argv[i]+7); 418 ctx.qry.sha1 = xstrdup(argv[i]+7);
419 ctx.qry.has_sha1 = 1; 419 ctx.qry.has_sha1 = 1;
420 } 420 }
421 if (!strncmp(argv[i], "--ofs=", 6)) { 421 if (!strncmp(argv[i], "--ofs=", 6)) {
422 ctx.qry.ofs = atoi(argv[i]+6); 422 ctx.qry.ofs = atoi(argv[i]+6);
423 } 423 }
424 } 424 }
425} 425}
426 426
427int main(int argc, const char **argv) 427int main(int argc, const char **argv)
428{ 428{
429 struct cacheitem item; 429 struct cacheitem item;
430 const char *cgit_config_env = getenv("CGIT_CONFIG"); 430 const char *cgit_config_env = getenv("CGIT_CONFIG");
431 431
432 prepare_context(&ctx); 432 prepare_context(&ctx);
433 item.st.st_mtime = time(NULL); 433 item.st.st_mtime = time(NULL);
434 cgit_repolist.length = 0; 434 cgit_repolist.length = 0;
435 cgit_repolist.count = 0; 435 cgit_repolist.count = 0;
436 cgit_repolist.repos = NULL; 436 cgit_repolist.repos = NULL;
437 437
438 cgit_read_config(cgit_config_env ? cgit_config_env : CGIT_CONFIG, 438 cgit_read_config(cgit_config_env ? cgit_config_env : CGIT_CONFIG,
439 config_cb); 439 config_cb);
440 if (getenv("SCRIPT_NAME")) 440 if (getenv("SCRIPT_NAME"))
441 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME")); 441 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
442 if (getenv("QUERY_STRING")) 442 if (getenv("QUERY_STRING"))
443 ctx.qry.raw = xstrdup(getenv("QUERY_STRING")); 443 ctx.qry.raw = xstrdup(getenv("QUERY_STRING"));
444 cgit_parse_args(argc, argv); 444 cgit_parse_args(argc, argv);
445 cgit_parse_query(ctx.qry.raw, querystring_cb); 445 cgit_parse_query(ctx.qry.raw, querystring_cb);
446 if (!cgit_prepare_cache(&item)) 446 if (!cgit_prepare_cache(&item))
447 return 0; 447 return 0;
448 if (ctx.cfg.nocache) { 448 if (ctx.cfg.nocache) {
449 cgit_fill_cache(&item, 0); 449 cgit_fill_cache(&item, 0);
450 } else { 450 } else {
451 cgit_check_cache(&item); 451 cgit_check_cache(&item);
452 cgit_print_cache(&item); 452 cgit_print_cache(&item);
453 } 453 }
454 return 0; 454 return 0;
455} 455}
diff --git a/cgit.h b/cgit.h
index b58676b..e82e9aa 100644
--- a/cgit.h
+++ b/cgit.h
@@ -1,242 +1,241 @@
1#ifndef CGIT_H 1#ifndef CGIT_H
2#define CGIT_H 2#define CGIT_H
3 3
4 4
5#include <git-compat-util.h> 5#include <git-compat-util.h>
6#include <cache.h> 6#include <cache.h>
7#include <grep.h> 7#include <grep.h>
8#include <object.h> 8#include <object.h>
9#include <tree.h> 9#include <tree.h>
10#include <commit.h> 10#include <commit.h>
11#include <tag.h> 11#include <tag.h>
12#include <diff.h> 12#include <diff.h>
13#include <diffcore.h> 13#include <diffcore.h>
14#include <refs.h> 14#include <refs.h>
15#include <revision.h> 15#include <revision.h>
16#include <log-tree.h> 16#include <log-tree.h>
17#include <archive.h> 17#include <archive.h>
18#include <xdiff/xdiff.h> 18#include <xdiff/xdiff.h>
19#include <utf8.h> 19#include <utf8.h>
20 20
21 21
22/* 22/*
23 * Dateformats used on misc. pages 23 * Dateformats used on misc. pages
24 */ 24 */
25#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" 25#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S"
26#define FMT_SHORTDATE "%Y-%m-%d" 26#define FMT_SHORTDATE "%Y-%m-%d"
27 27
28 28
29/* 29/*
30 * Limits used for relative dates 30 * Limits used for relative dates
31 */ 31 */
32#define TM_MIN 60 32#define TM_MIN 60
33#define TM_HOUR (TM_MIN * 60) 33#define TM_HOUR (TM_MIN * 60)
34#define TM_DAY (TM_HOUR * 24) 34#define TM_DAY (TM_HOUR * 24)
35#define TM_WEEK (TM_DAY * 7) 35#define TM_WEEK (TM_DAY * 7)
36#define TM_YEAR (TM_DAY * 365) 36#define TM_YEAR (TM_DAY * 365)
37#define TM_MONTH (TM_YEAR / 12.0) 37#define TM_MONTH (TM_YEAR / 12.0)
38 38
39 39
40/* 40/*
41 * Default encoding 41 * Default encoding
42 */ 42 */
43#define PAGE_ENCODING "UTF-8" 43#define PAGE_ENCODING "UTF-8"
44 44
45typedef void (*configfn)(const char *name, const char *value); 45typedef void (*configfn)(const char *name, const char *value);
46typedef void (*filepair_fn)(struct diff_filepair *pair); 46typedef void (*filepair_fn)(struct diff_filepair *pair);
47typedef void (*linediff_fn)(char *line, int len); 47typedef void (*linediff_fn)(char *line, int len);
48 48
49struct cacheitem { 49struct cacheitem {
50 char *name; 50 char *name;
51 struct stat st; 51 struct stat st;
52 int ttl; 52 int ttl;
53 int fd; 53 int fd;
54}; 54};
55 55
56struct cgit_repo { 56struct cgit_repo {
57 char *url; 57 char *url;
58 char *name; 58 char *name;
59 char *path; 59 char *path;
60 char *desc; 60 char *desc;
61 char *owner; 61 char *owner;
62 char *defbranch; 62 char *defbranch;
63 char *group; 63 char *group;
64 char *module_link; 64 char *module_link;
65 char *readme; 65 char *readme;
66 char *clone_url; 66 char *clone_url;
67 int snapshots; 67 int snapshots;
68 int enable_log_filecount; 68 int enable_log_filecount;
69 int enable_log_linecount; 69 int enable_log_linecount;
70}; 70};
71 71
72struct cgit_repolist { 72struct cgit_repolist {
73 int length; 73 int length;
74 int count; 74 int count;
75 struct cgit_repo *repos; 75 struct cgit_repo *repos;
76}; 76};
77 77
78struct commitinfo { 78struct commitinfo {
79 struct commit *commit; 79 struct commit *commit;
80 char *author; 80 char *author;
81 char *author_email; 81 char *author_email;
82 unsigned long author_date; 82 unsigned long author_date;
83 char *committer; 83 char *committer;
84 char *committer_email; 84 char *committer_email;
85 unsigned long committer_date; 85 unsigned long committer_date;
86 char *subject; 86 char *subject;
87 char *msg; 87 char *msg;
88 char *msg_encoding; 88 char *msg_encoding;
89}; 89};
90 90
91struct taginfo { 91struct taginfo {
92 char *tagger; 92 char *tagger;
93 char *tagger_email; 93 char *tagger_email;
94 int tagger_date; 94 int tagger_date;
95 char *msg; 95 char *msg;
96}; 96};
97 97
98struct refinfo { 98struct refinfo {
99 const char *refname; 99 const char *refname;
100 struct object *object; 100 struct object *object;
101 union { 101 union {
102 struct taginfo *tag; 102 struct taginfo *tag;
103 struct commitinfo *commit; 103 struct commitinfo *commit;
104 }; 104 };
105}; 105};
106 106
107struct reflist { 107struct reflist {
108 struct refinfo **refs; 108 struct refinfo **refs;
109 int alloc; 109 int alloc;
110 int count; 110 int count;
111}; 111};
112 112
113struct cgit_query { 113struct cgit_query {
114 int has_symref; 114 int has_symref;
115 int has_sha1; 115 int has_sha1;
116 char *raw; 116 char *raw;
117 char *repo; 117 char *repo;
118 char *page; 118 char *page;
119 char *search; 119 char *search;
120 char *grep; 120 char *grep;
121 char *head; 121 char *head;
122 char *sha1; 122 char *sha1;
123 char *sha2; 123 char *sha2;
124 char *path; 124 char *path;
125 char *name; 125 char *name;
126 int ofs; 126 int ofs;
127}; 127};
128 128
129struct cgit_config { 129struct cgit_config {
130 char *agefile; 130 char *agefile;
131 char *cache_root; 131 char *cache_root;
132 char *clone_prefix; 132 char *clone_prefix;
133 char *css; 133 char *css;
134 char *index_header; 134 char *index_header;
135 char *index_info; 135 char *index_info;
136 char *logo; 136 char *logo;
137 char *logo_link; 137 char *logo_link;
138 char *module_link; 138 char *module_link;
139 char *repo_group; 139 char *repo_group;
140 char *robots; 140 char *robots;
141 char *root_title; 141 char *root_title;
142 char *script_name; 142 char *script_name;
143 char *virtual_root; 143 char *virtual_root;
144 int cache_dynamic_ttl; 144 int cache_dynamic_ttl;
145 int cache_max_create_time; 145 int cache_max_create_time;
146 int cache_repo_ttl; 146 int cache_repo_ttl;
147 int cache_root_ttl; 147 int cache_root_ttl;
148 int cache_static_ttl; 148 int cache_static_ttl;
149 int enable_index_links; 149 int enable_index_links;
150 int enable_log_filecount; 150 int enable_log_filecount;
151 int enable_log_linecount; 151 int enable_log_linecount;
152 int max_commit_count; 152 int max_commit_count;
153 int max_lock_attempts; 153 int max_lock_attempts;
154 int max_msg_len; 154 int max_msg_len;
155 int max_repodesc_len; 155 int max_repodesc_len;
156 int nocache; 156 int nocache;
157 int renamelimit; 157 int renamelimit;
158 int snapshots; 158 int snapshots;
159 int summary_branches; 159 int summary_branches;
160 int summary_log; 160 int summary_log;
161 int summary_tags; 161 int summary_tags;
162}; 162};
163 163
164struct cgit_page { 164struct cgit_page {
165 time_t modified; 165 time_t modified;
166 time_t expires; 166 time_t expires;
167 char *mimetype; 167 char *mimetype;
168 char *charset; 168 char *charset;
169 char *filename; 169 char *filename;
170 char *title; 170 char *title;
171}; 171};
172 172
173struct cgit_context { 173struct cgit_context {
174 struct cgit_query qry; 174 struct cgit_query qry;
175 struct cgit_config cfg; 175 struct cgit_config cfg;
176 struct cgit_repo *repo; 176 struct cgit_repo *repo;
177 struct cgit_page page; 177 struct cgit_page page;
178}; 178};
179 179
180struct cgit_snapshot_format { 180struct cgit_snapshot_format {
181 const char *suffix; 181 const char *suffix;
182 const char *mimetype; 182 const char *mimetype;
183 write_archive_fn_t write_func; 183 write_archive_fn_t write_func;
184 int bit; 184 int bit;
185}; 185};
186 186
187extern const char *cgit_version; 187extern const char *cgit_version;
188 188
189extern struct cgit_repolist cgit_repolist; 189extern struct cgit_repolist cgit_repolist;
190extern struct cgit_context ctx; 190extern struct cgit_context ctx;
191extern const struct cgit_snapshot_format cgit_snapshot_formats[]; 191extern const struct cgit_snapshot_format cgit_snapshot_formats[];
192extern int cgit_cmd;
193 192
194extern struct cgit_repo *cgit_add_repo(const char *url); 193extern struct cgit_repo *cgit_add_repo(const char *url);
195extern struct cgit_repo *cgit_get_repoinfo(const char *url); 194extern struct cgit_repo *cgit_get_repoinfo(const char *url);
196extern void cgit_repo_config_cb(const char *name, const char *value); 195extern void cgit_repo_config_cb(const char *name, const char *value);
197 196
198extern int chk_zero(int result, char *msg); 197extern int chk_zero(int result, char *msg);
199extern int chk_positive(int result, char *msg); 198extern int chk_positive(int result, char *msg);
200extern int chk_non_negative(int result, char *msg); 199extern int chk_non_negative(int result, char *msg);
201 200
202extern int hextoint(char c); 201extern int hextoint(char c);
203extern char *trim_end(const char *str, char c); 202extern char *trim_end(const char *str, char c);
204extern char *strlpart(char *txt, int maxlen); 203extern char *strlpart(char *txt, int maxlen);
205extern char *strrpart(char *txt, int maxlen); 204extern char *strrpart(char *txt, int maxlen);
206 205
207extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); 206extern void cgit_add_ref(struct reflist *list, struct refinfo *ref);
208extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, 207extern int cgit_refs_cb(const char *refname, const unsigned char *sha1,
209 int flags, void *cb_data); 208 int flags, void *cb_data);
210 209
211extern void *cgit_free_commitinfo(struct commitinfo *info); 210extern void *cgit_free_commitinfo(struct commitinfo *info);
212 211
213extern int cgit_diff_files(const unsigned char *old_sha1, 212extern int cgit_diff_files(const unsigned char *old_sha1,
214 const unsigned char *new_sha1, 213 const unsigned char *new_sha1,
215 linediff_fn fn); 214 linediff_fn fn);
216 215
217extern void cgit_diff_tree(const unsigned char *old_sha1, 216extern void cgit_diff_tree(const unsigned char *old_sha1,
218 const unsigned char *new_sha1, 217 const unsigned char *new_sha1,
219 filepair_fn fn, const char *prefix); 218 filepair_fn fn, const char *prefix);
220 219
221extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); 220extern void cgit_diff_commit(struct commit *commit, filepair_fn fn);
222 221
223extern char *fmt(const char *format,...); 222extern char *fmt(const char *format,...);
224 223
225extern int cgit_read_config(const char *filename, configfn fn); 224extern int cgit_read_config(const char *filename, configfn fn);
226extern int cgit_parse_query(char *txt, configfn fn); 225extern int cgit_parse_query(char *txt, configfn fn);
227extern struct commitinfo *cgit_parse_commit(struct commit *commit); 226extern struct commitinfo *cgit_parse_commit(struct commit *commit);
228extern struct taginfo *cgit_parse_tag(struct tag *tag); 227extern struct taginfo *cgit_parse_tag(struct tag *tag);
229extern void cgit_parse_url(const char *url); 228extern void cgit_parse_url(const char *url);
230 229
231extern char *cache_safe_filename(const char *unsafe); 230extern char *cache_safe_filename(const char *unsafe);
232extern int cache_lock(struct cacheitem *item); 231extern int cache_lock(struct cacheitem *item);
233extern int cache_unlock(struct cacheitem *item); 232extern int cache_unlock(struct cacheitem *item);
234extern int cache_cancel_lock(struct cacheitem *item); 233extern int cache_cancel_lock(struct cacheitem *item);
235extern int cache_exist(struct cacheitem *item); 234extern int cache_exist(struct cacheitem *item);
236extern int cache_expired(struct cacheitem *item); 235extern int cache_expired(struct cacheitem *item);
237 236
238extern const char *cgit_repobasename(const char *reponame); 237extern const char *cgit_repobasename(const char *reponame);
239 238
240extern int cgit_parse_snapshots_mask(const char *str); 239extern int cgit_parse_snapshots_mask(const char *str);
241 240
242#endif /* CGIT_H */ 241#endif /* CGIT_H */