|
diff --git a/shared.c b/shared.c index f7f43b2..1a5b866 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -25,12 +25,13 @@ char *cgit_virtual_root = NULL; |
25 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
25 | char *cgit_script_name = CGIT_SCRIPT_NAME; |
26 | char *cgit_cache_root = "/var/cache/cgit"; |
26 | char *cgit_cache_root = "/var/cache/cgit"; |
27 | char *cgit_repo_group = NULL; |
27 | char *cgit_repo_group = NULL; |
28 | |
28 | |
29 | int cgit_nocache = 0; |
29 | int cgit_nocache = 0; |
30 | int cgit_snapshots = 0; |
30 | int cgit_snapshots = 0; |
| |
31 | int cgit_enable_index_links = 0; |
31 | int cgit_enable_log_filecount = 0; |
32 | int cgit_enable_log_filecount = 0; |
32 | int cgit_enable_log_linecount = 0; |
33 | int cgit_enable_log_linecount = 0; |
33 | int cgit_max_lock_attempts = 5; |
34 | int cgit_max_lock_attempts = 5; |
34 | int cgit_cache_root_ttl = 5; |
35 | int cgit_cache_root_ttl = 5; |
35 | int cgit_cache_repo_ttl = 5; |
36 | int cgit_cache_repo_ttl = 5; |
36 | int cgit_cache_dynamic_ttl = 5; |
37 | int cgit_cache_dynamic_ttl = 5; |
@@ -145,12 +146,14 @@ void cgit_global_config_cb(const char *name, const char *value) |
145 | else if (!strcmp(name, "virtual-root")) |
146 | else if (!strcmp(name, "virtual-root")) |
146 | cgit_virtual_root = xstrdup(value); |
147 | cgit_virtual_root = xstrdup(value); |
147 | else if (!strcmp(name, "nocache")) |
148 | else if (!strcmp(name, "nocache")) |
148 | cgit_nocache = atoi(value); |
149 | cgit_nocache = atoi(value); |
149 | else if (!strcmp(name, "snapshots")) |
150 | else if (!strcmp(name, "snapshots")) |
150 | cgit_snapshots = atoi(value); |
151 | cgit_snapshots = atoi(value); |
| |
152 | else if (!strcmp(name, "enable-index-links")) |
| |
153 | cgit_enable_index_links = atoi(value); |
151 | else if (!strcmp(name, "enable-log-filecount")) |
154 | else if (!strcmp(name, "enable-log-filecount")) |
152 | cgit_enable_log_filecount = atoi(value); |
155 | cgit_enable_log_filecount = atoi(value); |
153 | else if (!strcmp(name, "enable-log-linecount")) |
156 | else if (!strcmp(name, "enable-log-linecount")) |
154 | cgit_enable_log_linecount = atoi(value); |
157 | cgit_enable_log_linecount = atoi(value); |
155 | else if (!strcmp(name, "cache-root")) |
158 | else if (!strcmp(name, "cache-root")) |
156 | cgit_cache_root = xstrdup(value); |
159 | cgit_cache_root = xstrdup(value); |
@@ -224,13 +227,13 @@ void cgit_querystring_cb(const char *name, const char *value) |
224 | } else if (!strcmp(name, "id2")) { |
227 | } else if (!strcmp(name, "id2")) { |
225 | cgit_query_sha2 = xstrdup(value); |
228 | cgit_query_sha2 = xstrdup(value); |
226 | cgit_query_has_sha1 = 1; |
229 | cgit_query_has_sha1 = 1; |
227 | } else if (!strcmp(name, "ofs")) { |
230 | } else if (!strcmp(name, "ofs")) { |
228 | cgit_query_ofs = atoi(value); |
231 | cgit_query_ofs = atoi(value); |
229 | } else if (!strcmp(name, "path")) { |
232 | } else if (!strcmp(name, "path")) { |
230 | cgit_query_path = xstrdup(value); |
233 | cgit_query_path = trim_end(value, '/'); |
231 | } else if (!strcmp(name, "name")) { |
234 | } else if (!strcmp(name, "name")) { |
232 | cgit_query_name = xstrdup(value); |
235 | cgit_query_name = xstrdup(value); |
233 | } |
236 | } |
234 | } |
237 | } |
235 | |
238 | |
236 | void *cgit_free_commitinfo(struct commitinfo *info) |
239 | void *cgit_free_commitinfo(struct commitinfo *info) |
@@ -253,12 +256,34 @@ int hextoint(char c) |
253 | else if (c >= '0' && c <= '9') |
256 | else if (c >= '0' && c <= '9') |
254 | return c - '0'; |
257 | return c - '0'; |
255 | else |
258 | else |
256 | return -1; |
259 | return -1; |
257 | } |
260 | } |
258 | |
261 | |
| |
262 | char *trim_end(const char *str, char c) |
| |
263 | { |
| |
264 | int len; |
| |
265 | char *s, *t; |
| |
266 | |
| |
267 | if (str == NULL) |
| |
268 | return NULL; |
| |
269 | t = (char *)str; |
| |
270 | len = strlen(t); |
| |
271 | while(len > 0 && t[len - 1] == c) |
| |
272 | len--; |
| |
273 | |
| |
274 | if (len == 0) |
| |
275 | return NULL; |
| |
276 | |
| |
277 | c = t[len]; |
| |
278 | t[len] = '\0'; |
| |
279 | s = xstrdup(t); |
| |
280 | t[len] = c; |
| |
281 | return s; |
| |
282 | } |
| |
283 | |
259 | void cgit_diff_tree_cb(struct diff_queue_struct *q, |
284 | void cgit_diff_tree_cb(struct diff_queue_struct *q, |
260 | struct diff_options *options, void *data) |
285 | struct diff_options *options, void *data) |
261 | { |
286 | { |
262 | int i; |
287 | int i; |
263 | |
288 | |
264 | for (i = 0; i < q->nr; i++) { |
289 | for (i = 0; i < q->nr; i++) { |
|