]> gitweb.ps.run Git - ps-cgit/blobdiff - cgit.c
about: allow to give head from query
[ps-cgit] / cgit.c
diff --git a/cgit.c b/cgit.c
index 08d81a1d4b632af9b725a0a2dbf553cff4d3e6b7..2de6d7f84c530f30851c2b3931eaec11ca722b1c 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -428,7 +428,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 +507,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);