]> git.cameronkatri.com Git - cgit.git/blobdiff - ui-shared.c
Bump version.
[cgit.git] / ui-shared.c
index 8a786e0a3e27e63d1e6f19c28b85e0fc1c326673..739505a865cc7660621f28666474ec9c6d624718 100644 (file)
@@ -133,20 +133,25 @@ const char *cgit_repobasename(const char *reponame)
        static char rvbuf[1024];
        int p;
        const char *rv;
-       strncpy(rvbuf, reponame, sizeof(rvbuf));
-       if (rvbuf[sizeof(rvbuf)-1])
+       size_t len;
+
+       len = strlcpy(rvbuf, reponame, sizeof(rvbuf));
+       if (len >= sizeof(rvbuf))
                die("cgit_repobasename: truncated repository name '%s'", reponame);
-       p = strlen(rvbuf)-1;
+       p = len - 1;
        /* strip trailing slashes */
-       while (p && rvbuf[p] == '/') rvbuf[p--] = 0;
+       while (p && rvbuf[p] == '/')
+               rvbuf[p--] = '\0';
        /* strip trailing .git */
        if (p >= 3 && starts_with(&rvbuf[p-3], ".git")) {
-               p -= 3; rvbuf[p--] = 0;
+               p -= 3;
+               rvbuf[p--] = '\0';
        }
        /* strip more trailing slashes if any */
-       while ( p && rvbuf[p] == '/') rvbuf[p--] = 0;
+       while (p && rvbuf[p] == '/')
+               rvbuf[p--] = '\0';
        /* find last slash in the remaining string */
-       rv = strrchr(rvbuf,'/');
+       rv = strrchr(rvbuf, '/');
        if (rv)
                return ++rv;
        return rvbuf;
@@ -775,6 +780,8 @@ void cgit_print_docstart(void)
                cgit_add_clone_urls(print_rel_vcs_link);
        if (ctx.cfg.head_include)
                html_include(ctx.cfg.head_include);
+       if (ctx.repo && ctx.repo->extra_head_content)
+               html(ctx.repo->extra_head_content);
        html("</head>\n");
        html("<body>\n");
        if (ctx.cfg.header)
@@ -977,8 +984,6 @@ static void print_header(void)
        } else {
                if (ctx.cfg.root_desc)
                        html_txt(ctx.cfg.root_desc);
-               else if (ctx.cfg.index_info)
-                       html_include(ctx.cfg.index_info);
        }
        html("</td></tr></table>\n");
 }
@@ -1114,7 +1119,7 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base,
 void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
                               const char *separator)
 {
-       const struct cgit_snapshot_formatf;
+       const struct cgit_snapshot_format *f;
        struct strbuf filename = STRBUF_INIT;
        const char *basename;
        size_t prefixlen;
@@ -1127,7 +1132,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
 
        prefixlen = filename.len;
        for (f = cgit_snapshot_formats; f->suffix; f++) {
-               if (!(repo->snapshots & f->bit))
+               if (!(repo->snapshots & cgit_snapshot_format_bit(f)))
                        continue;
                strbuf_setlen(&filename, prefixlen);
                strbuf_addstr(&filename, f->suffix);
@@ -1139,6 +1144,13 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
                        cgit_snapshot_link("sig", NULL, NULL, NULL, NULL,
                                           filename.buf);
                        html(")");
+               } else if (starts_with(f->suffix, ".tar") && cgit_snapshot_get_sig(ref, &cgit_snapshot_formats[0])) {
+                       strbuf_setlen(&filename, strlen(filename.buf) - strlen(f->suffix));
+                       strbuf_addstr(&filename, ".tar.asc");
+                       html(" (");
+                       cgit_snapshot_link("sig", NULL, NULL, NULL, NULL,
+                                          filename.buf);
+                       html(")");
                }
                html(separator);
        }