summaryrefslogtreecommitdiffabout
path: root/shared.c
authorLars Hjemli <hjemli@gmail.com>2007-06-29 18:32:08 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-06-29 18:32:08 (UTC)
commit16a3d2779ccd56bf7954d98da547247d8796544b (patch) (unidiff)
tree86d2ed41adc3de842c7518d614ea49ca0200e4d2 /shared.c
parentf69250358a74efa5d7d9c562b2cdd80fad1430f1 (diff)
parent103940fe6b0914dc42b8b033d1d328f38135ca5f (diff)
downloadcgit-16a3d2779ccd56bf7954d98da547247d8796544b.zip
cgit-16a3d2779ccd56bf7954d98da547247d8796544b.tar.gz
cgit-16a3d2779ccd56bf7954d98da547247d8796544b.tar.bz2
Merge branch 'lh/menu'
* lh/menu: Add ofs argument to cgit_log_link and use it in ui-log.c Add trim_end() and use it to remove trailing slashes from repo paths Do not include current path in the "tree" menu link Add setting to enable/disable extra links on index page Change S/L/T to summary/log/tree Change "files" to "tree" Include querystring as part of cached filename for repo summary page Add more menuitems on repo pages
Diffstat (limited to 'shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--shared.c27
1 files changed, 26 insertions, 1 deletions
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;
25char *cgit_script_name = CGIT_SCRIPT_NAME; 25char *cgit_script_name = CGIT_SCRIPT_NAME;
26char *cgit_cache_root = "/var/cache/cgit"; 26char *cgit_cache_root = "/var/cache/cgit";
27char *cgit_repo_group = NULL; 27char *cgit_repo_group = NULL;
28 28
29int cgit_nocache = 0; 29int cgit_nocache = 0;
30int cgit_snapshots = 0; 30int cgit_snapshots = 0;
31int cgit_enable_index_links = 0;
31int cgit_enable_log_filecount = 0; 32int cgit_enable_log_filecount = 0;
32int cgit_enable_log_linecount = 0; 33int cgit_enable_log_linecount = 0;
33int cgit_max_lock_attempts = 5; 34int cgit_max_lock_attempts = 5;
34int cgit_cache_root_ttl = 5; 35int cgit_cache_root_ttl = 5;
35int cgit_cache_repo_ttl = 5; 36int cgit_cache_repo_ttl = 5;
36int cgit_cache_dynamic_ttl = 5; 37int 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
236void *cgit_free_commitinfo(struct commitinfo *info) 239void *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
262char *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
259void cgit_diff_tree_cb(struct diff_queue_struct *q, 284void 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++) {