]> git.cameronkatri.com Git - cgit.git/blobdiff - cgit.c
git: update to v2.20.0
[cgit.git] / cgit.c
diff --git a/cgit.c b/cgit.c
index d2f7b9c7bbb4f30e0c2ee813c79b50466e1a5d3e..2f07e6d5c88ddb9a9647da519d5044513f39a5e4 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -23,7 +23,7 @@ static void add_mimetype(const char *name, const char *value)
 {
        struct string_list_item *item;
 
-       item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name));
+       item = string_list_insert(&ctx.cfg.mimetypes, name);
        item->util = xstrdup(value);
 }
 
@@ -46,6 +46,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
                repo->homepage = xstrdup(value);
        else if (!strcmp(name, "defbranch"))
                repo->defbranch = xstrdup(value);
+       else if (!strcmp(name, "extra-head-content"))
+               repo->extra_head_content = xstrdup(value);
        else if (!strcmp(name, "snapshots"))
                repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
        else if (!strcmp(name, "enable-commit-graph"))
@@ -111,7 +113,7 @@ static void config_cb(const char *name, const char *value)
 {
        const char *arg;
 
-       if (!strcmp(name, "section") || !strcmp(name, "repo.group"))
+       if (!strcmp(name, "section"))
                ctx.cfg.section = xstrdup(value);
        else if (!strcmp(name, "repo.url"))
                ctx.repo = cgit_add_repo(value);
@@ -139,20 +141,14 @@ static void config_cb(const char *name, const char *value)
                ctx.cfg.header = xstrdup(value);
        else if (!strcmp(name, "logo"))
                ctx.cfg.logo = xstrdup(value);
-       else if (!strcmp(name, "index-header"))
-               ctx.cfg.index_header = xstrdup(value);
-       else if (!strcmp(name, "index-info"))
-               ctx.cfg.index_info = xstrdup(value);
        else if (!strcmp(name, "logo-link"))
                ctx.cfg.logo_link = xstrdup(value);
        else if (!strcmp(name, "module-link"))
                ctx.cfg.module_link = xstrdup(value);
        else if (!strcmp(name, "strict-export"))
                ctx.cfg.strict_export = xstrdup(value);
-       else if (!strcmp(name, "virtual-root")) {
+       else if (!strcmp(name, "virtual-root"))
                ctx.cfg.virtual_root = ensure_end(value, '/');
-       } else if (!strcmp(name, "nocache"))
-               ctx.cfg.nocache = atoi(value);
        else if (!strcmp(name, "noplainemail"))
                ctx.cfg.noplainemail = atoi(value);
        else if (!strcmp(name, "noheader"))
@@ -236,7 +232,7 @@ static void config_cb(const char *name, const char *value)
        else if (!strcmp(name, "project-list"))
                ctx.cfg.project_list = xstrdup(expand_macros(value));
        else if (!strcmp(name, "scan-path"))
-               if (!ctx.cfg.nocache && ctx.cfg.cache_size)
+               if (ctx.cfg.cache_size)
                        process_cached_repolist(expand_macros(value));
                else if (ctx.cfg.project_list)
                        scan_projects(expand_macros(value),
@@ -355,7 +351,6 @@ static void prepare_context(void)
 {
        memset(&ctx, 0, sizeof(ctx));
        ctx.cfg.agefile = "info/web/last-modified";
-       ctx.cfg.nocache = 0;
        ctx.cfg.cache_size = 0;
        ctx.cfg.cache_max_create_time = 5;
        ctx.cfg.cache_root = CGIT_CACHE_ROOT;
@@ -421,7 +416,7 @@ static void prepare_context(void)
        ctx.page.modified = time(NULL);
        ctx.page.expires = ctx.page.modified;
        ctx.page.etag = NULL;
-       memset(&ctx.cfg.mimetypes, 0, sizeof(struct string_list));
+       string_list_init(&ctx.cfg.mimetypes, 1);
        if (ctx.env.script_name)
                ctx.cfg.script_name = xstrdup(ctx.env.script_name);
        if (ctx.env.query_string)
@@ -650,7 +645,7 @@ static inline void open_auth_filter(const char *function)
                ctx.env.https ? ctx.env.https : "",
                ctx.qry.repo ? ctx.qry.repo : "",
                ctx.qry.page ? ctx.qry.page : "",
-               ctx.qry.url ? ctx.qry.url : "",
+               cgit_currentfullurl(),
                cgit_loginurl());
 }
 
@@ -664,13 +659,13 @@ static inline void open_auth_filter(const char *function)
 static inline void authenticate_post(void)
 {
        char buffer[MAX_AUTHENTICATION_POST_BYTES];
-       unsigned int len;
+       ssize_t len;
 
        open_auth_filter("authenticate-post");
        len = ctx.env.content_length;
        if (len > MAX_AUTHENTICATION_POST_BYTES)
                len = MAX_AUTHENTICATION_POST_BYTES;
-       if (read(STDIN_FILENO, buffer, len) < 0)
+       if ((len = read(STDIN_FILENO, buffer, len)) < 0)
                die_errno("Could not read POST from stdin");
        if (write(STDOUT_FILENO, buffer, len) < 0)
                die_errno("Could not write POST to stdout");
@@ -765,7 +760,7 @@ static char *build_snapshot_setting(int bitmap)
        struct strbuf result = STRBUF_INIT;
 
        for (f = cgit_snapshot_formats; f->suffix; f++) {
-               if (f->bit & bitmap) {
+               if (cgit_snapshot_format_bit(f) & bitmap) {
                        if (result.len)
                                strbuf_addch(&result, ' ');
                        strbuf_addstr(&result, f->suffix);
@@ -804,6 +799,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
        }
        if (repo->defbranch)
                fprintf(f, "repo.defbranch=%s\n", repo->defbranch);
+       if (repo->extra_head_content)
+               fprintf(f, "repo.extra-head-content=%s\n", repo->extra_head_content);
        if (repo->module_link)
                fprintf(f, "repo.module-link=%s\n", repo->module_link);
        if (repo->section)
@@ -833,6 +830,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
                fprintf(f, "repo.snapshots=%s\n", tmp ? tmp : "");
                free(tmp);
        }
+       if (repo->snapshot_prefix)
+               fprintf(f, "repo.snapshot-prefix=%s\n", repo->snapshot_prefix);
        if (repo->max_stats != ctx.cfg.max_stats)
                fprintf(f, "repo.max-stats=%s\n",
                        cgit_find_stats_periodname(repo->max_stats));
@@ -973,8 +972,6 @@ static void cgit_parse_args(int argc, const char **argv)
                }
                if (skip_prefix(argv[i], "--cache=", &arg)) {
                        ctx.cfg.cache_root = xstrdup(arg);
-               } else if (!strcmp(argv[i], "--nocache")) {
-                       ctx.cfg.nocache = 1;
                } else if (!strcmp(argv[i], "--nohttp")) {
                        ctx.env.no_http = "1";
                } else if (skip_prefix(argv[i], "--query=", &arg)) {
@@ -1095,8 +1092,6 @@ int cmd_main(int argc, const char **argv)
        else
                ctx.page.expires += ttl * 60;
        if (!ctx.env.authenticated || (ctx.env.request_method && !strcmp(ctx.env.request_method, "HEAD")))
-               ctx.cfg.nocache = 1;
-       if (ctx.cfg.nocache)
                ctx.cfg.cache_size = 0;
        err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root,
                            ctx.qry.raw, ttl, process_request);