diff options
Diffstat (limited to 'cgit.c')
-rw-r--r-- | cgit.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -29,15 +29,17 @@ void add_mimetype(const char *name, const char *value) | |||
29 | struct cgit_filter *new_filter(const char *cmd, int extra_args) | 29 | struct cgit_filter *new_filter(const char *cmd, int extra_args) |
30 | { | 30 | { |
31 | struct cgit_filter *f; | 31 | struct cgit_filter *f; |
32 | int args_size = 0; | ||
32 | 33 | ||
33 | if (!cmd || !cmd[0]) | 34 | if (!cmd || !cmd[0]) |
34 | return NULL; | 35 | return NULL; |
35 | 36 | ||
36 | f = xmalloc(sizeof(struct cgit_filter)); | 37 | f = xmalloc(sizeof(struct cgit_filter)); |
37 | f->cmd = xstrdup(cmd); | 38 | f->cmd = xstrdup(cmd); |
38 | f->argv = xmalloc((2 + extra_args) * sizeof(char *)); | 39 | args_size = (2 + extra_args) * sizeof(char *); |
40 | f->argv = xmalloc(args_size); | ||
41 | memset(f->argv, 0, args_size); | ||
39 | f->argv[0] = f->cmd; | 42 | f->argv[0] = f->cmd; |
40 | f->argv[1] = NULL; | ||
41 | return f; | 43 | return f; |
42 | } | 44 | } |
43 | 45 | ||
@@ -57,6 +59,8 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
57 | repo->defbranch = xstrdup(value); | 59 | repo->defbranch = xstrdup(value); |
58 | else if (!strcmp(name, "snapshots")) | 60 | else if (!strcmp(name, "snapshots")) |
59 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); | 61 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); |
62 | else if (!strcmp(name, "enable-commit-graph")) | ||
63 | repo->enable_commit_graph = ctx.cfg.enable_commit_graph * atoi(value); | ||
60 | else if (!strcmp(name, "enable-log-filecount")) | 64 | else if (!strcmp(name, "enable-log-filecount")) |
61 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 65 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
62 | else if (!strcmp(name, "enable-log-linecount")) | 66 | else if (!strcmp(name, "enable-log-linecount")) |
@@ -71,9 +75,13 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
71 | repo->module_link= xstrdup(value); | 75 | repo->module_link= xstrdup(value); |
72 | else if (!strcmp(name, "section")) | 76 | else if (!strcmp(name, "section")) |
73 | repo->section = xstrdup(value); | 77 | repo->section = xstrdup(value); |
74 | else if (!strcmp(name, "readme") && value != NULL) { | 78 | else if (!strcmp(name, "readme") && value != NULL) |
75 | repo->readme = xstrdup(value); | 79 | repo->readme = xstrdup(value); |
76 | } else if (ctx.cfg.enable_filter_overrides) { | 80 | else if (!strcmp(name, "logo") && value != NULL) |
81 | repo->logo = xstrdup(value); | ||
82 | else if (!strcmp(name, "logo-link") && value != NULL) | ||
83 | repo->logo_link = xstrdup(value); | ||
84 | else if (ctx.cfg.enable_filter_overrides) { | ||
77 | if (!strcmp(name, "about-filter")) | 85 | if (!strcmp(name, "about-filter")) |
78 | repo->about_filter = new_filter(value, 0); | 86 | repo->about_filter = new_filter(value, 0); |
79 | else if (!strcmp(name, "commit-filter")) | 87 | else if (!strcmp(name, "commit-filter")) |
@@ -143,6 +151,8 @@ void config_cb(const char *name, const char *value) | |||
143 | ctx.cfg.enable_http_clone = atoi(value); | 151 | ctx.cfg.enable_http_clone = atoi(value); |
144 | else if (!strcmp(name, "enable-index-links")) | 152 | else if (!strcmp(name, "enable-index-links")) |
145 | ctx.cfg.enable_index_links = atoi(value); | 153 | ctx.cfg.enable_index_links = atoi(value); |
154 | else if (!strcmp(name, "enable-commit-graph")) | ||
155 | ctx.cfg.enable_commit_graph = atoi(value); | ||
146 | else if (!strcmp(name, "enable-log-filecount")) | 156 | else if (!strcmp(name, "enable-log-filecount")) |
147 | ctx.cfg.enable_log_filecount = atoi(value); | 157 | ctx.cfg.enable_log_filecount = atoi(value); |
148 | else if (!strcmp(name, "enable-log-linecount")) | 158 | else if (!strcmp(name, "enable-log-linecount")) |
@@ -197,6 +207,8 @@ void config_cb(const char *name, const char *value) | |||
197 | ctx.cfg.project_list, repo_config); | 207 | ctx.cfg.project_list, repo_config); |
198 | else | 208 | else |
199 | scan_tree(expand_macros(value), repo_config); | 209 | scan_tree(expand_macros(value), repo_config); |
210 | else if (!strcmp(name, "scan-hidden-path")) | ||
211 | ctx.cfg.scan_hidden_path = atoi(value); | ||
200 | else if (!strcmp(name, "section-from-path")) | 212 | else if (!strcmp(name, "section-from-path")) |
201 | ctx.cfg.section_from_path = atoi(value); | 213 | ctx.cfg.section_from_path = atoi(value); |
202 | else if (!strcmp(name, "source-filter")) | 214 | else if (!strcmp(name, "source-filter")) |
@@ -318,6 +330,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
318 | ctx->cfg.robots = "index, nofollow"; | 330 | ctx->cfg.robots = "index, nofollow"; |
319 | ctx->cfg.root_title = "Git repository browser"; | 331 | ctx->cfg.root_title = "Git repository browser"; |
320 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; | 332 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; |
333 | ctx->cfg.scan_hidden_path = 0; | ||
321 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; | 334 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; |
322 | ctx->cfg.section = ""; | 335 | ctx->cfg.section = ""; |
323 | ctx->cfg.summary_branches = 10; | 336 | ctx->cfg.summary_branches = 10; |
@@ -550,6 +563,8 @@ void print_repo(FILE *f, struct cgit_repo *repo) | |||
550 | fprintf(f, "repo.section=%s\n", repo->section); | 563 | fprintf(f, "repo.section=%s\n", repo->section); |
551 | if (repo->clone_url) | 564 | if (repo->clone_url) |
552 | fprintf(f, "repo.clone-url=%s\n", repo->clone_url); | 565 | fprintf(f, "repo.clone-url=%s\n", repo->clone_url); |
566 | fprintf(f, "repo.enable-commit-graph=%d\n", | ||
567 | repo->enable_commit_graph); | ||
553 | fprintf(f, "repo.enable-log-filecount=%d\n", | 568 | fprintf(f, "repo.enable-log-filecount=%d\n", |
554 | repo->enable_log_filecount); | 569 | repo->enable_log_filecount); |
555 | fprintf(f, "repo.enable-log-linecount=%d\n", | 570 | fprintf(f, "repo.enable-log-linecount=%d\n", |
@@ -749,10 +764,11 @@ int main(int argc, const char **argv) | |||
749 | http_parse_querystring(ctx.qry.raw, querystring_cb); | 764 | http_parse_querystring(ctx.qry.raw, querystring_cb); |
750 | 765 | ||
751 | /* If virtual-root isn't specified in cgitrc, lets pretend | 766 | /* If virtual-root isn't specified in cgitrc, lets pretend |
752 | * that virtual-root equals SCRIPT_NAME. | 767 | * that virtual-root equals SCRIPT_NAME, minus any possibly |
768 | * trailing slashes. | ||
753 | */ | 769 | */ |
754 | if (!ctx.cfg.virtual_root) | 770 | if (!ctx.cfg.virtual_root) |
755 | ctx.cfg.virtual_root = ctx.cfg.script_name; | 771 | ctx.cfg.virtual_root = trim_end(ctx.cfg.script_name, '/'); |
756 | 772 | ||
757 | /* If no url parameter is specified on the querystring, lets | 773 | /* If no url parameter is specified on the querystring, lets |
758 | * use PATH_INFO as url. This allows cgit to work with virtual | 774 | * use PATH_INFO as url. This allows cgit to work with virtual |