aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/cgit.c b/cgit.c
index 08d81a1..e616292 100644
--- a/cgit.c
+++ b/cgit.c
@@ -142,7 +142,9 @@ static void config_cb(const char *name, const char *value)
else if (!strcmp(name, "root-readme"))
ctx.cfg.root_readme = xstrdup(value);
else if (!strcmp(name, "css"))
- ctx.cfg.css = xstrdup(value);
+ string_list_append(&ctx.cfg.css, xstrdup(value));
+ else if (!strcmp(name, "js"))
+ string_list_append(&ctx.cfg.js, xstrdup(value));
else if (!strcmp(name, "favicon"))
ctx.cfg.favicon = xstrdup(value);
else if (!strcmp(name, "footer"))
@@ -237,9 +239,11 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.max_repodesc_len = atoi(value);
else if (!strcmp(name, "max-blob-size"))
ctx.cfg.max_blob_size = atoi(value);
- else if (!strcmp(name, "max-repo-count"))
+ else if (!strcmp(name, "max-repo-count")) {
ctx.cfg.max_repo_count = atoi(value);
- else if (!strcmp(name, "max-commit-count"))
+ if (ctx.cfg.max_repo_count <= 0)
+ ctx.cfg.max_repo_count = INT_MAX;
+ } else if (!strcmp(name, "max-commit-count"))
ctx.cfg.max_commit_count = atoi(value);
else if (!strcmp(name, "project-list"))
ctx.cfg.project_list = xstrdup(expand_macros(value));
@@ -376,7 +380,6 @@ static void prepare_context(void)
ctx.cfg.case_sensitive_sort = 1;
ctx.cfg.branch_sort = 0;
ctx.cfg.commit_sort = 0;
- ctx.cfg.css = "/cgit.css";
ctx.cfg.logo = "/cgit.png";
ctx.cfg.favicon = "/favicon.ico";
ctx.cfg.local_time = 0;
@@ -428,7 +431,7 @@ static void prepare_context(void)
ctx.page.modified = time(NULL);
ctx.page.expires = ctx.page.modified;
ctx.page.etag = NULL;
- string_list_init(&ctx.cfg.mimetypes, 1);
+ string_list_init_dup(&ctx.cfg.mimetypes);
if (ctx.env.script_name)
ctx.cfg.script_name = xstrdup(ctx.env.script_name);
if (ctx.env.query_string)
@@ -507,9 +510,11 @@ static inline void parse_readme(const char *readme, char **filename, char **ref,
/* Check if the readme is tracked in the git repo. */
colon = strchr(readme, ':');
if (colon && strlen(colon) > 1) {
- /* If it starts with a colon, we want to use
- * the default branch */
- if (colon == readme && repo->defbranch)
+ /* If it starts with a colon, we want to use head given
+ * from query or the default branch */
+ if (colon == readme && ctx.qry.head)
+ *ref = xstrdup(ctx.qry.head);
+ else if (colon == readme && repo->defbranch)
*ref = xstrdup(repo->defbranch);
else
*ref = xstrndup(readme, colon - readme);
@@ -626,7 +631,7 @@ static int prepare_repo_cmd(int nongit)
return 1;
}
- if (get_oid(ctx.qry.head, &oid)) {
+ if (repo_get_oid(the_repository, ctx.qry.head, &oid)) {
char *old_head = ctx.qry.head;
ctx.qry.head = xstrdup(ctx.repo->defbranch);
cgit_print_error_page(404, "Not found",