X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/023d933121ca7352a069f3886caf6fbe958ba27d..3e244a0ccaef8303302a2c462f36b8bdf3634a46:/ui-tag.c diff --git a/ui-tag.c b/ui-tag.c index 39e4cb8..0afc663 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -1,12 +1,13 @@ /* ui-tag.c: display a tag * - * Copyright (C) 2007 Lars Hjemli + * Copyright (C) 2006-2014 cgit Development Team * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ #include "cgit.h" +#include "ui-tag.h" #include "html.h" #include "ui-shared.h" @@ -30,7 +31,7 @@ static void print_tag_content(char *buf) } } -void print_download_links(char *revname) +static void print_download_links(char *revname) { html("download"); cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, @@ -40,6 +41,7 @@ void print_download_links(char *revname) void cgit_print_tag(char *revname) { + struct strbuf fullref = STRBUF_INIT; unsigned char sha1[20]; struct object *obj; struct tag *tag; @@ -48,21 +50,26 @@ void cgit_print_tag(char *revname) if (!revname) revname = ctx.qry.head; - if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { - cgit_print_error(fmt("Bad tag reference: %s", revname)); - return; + strbuf_addf(&fullref, "refs/tags/%s", revname); + if (get_sha1(fullref.buf, sha1)) { + cgit_print_error_page(404, "Not found", + "Bad tag reference: %s", revname); + goto cleanup; } obj = parse_object(sha1); if (!obj) { - cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); - return; + cgit_print_error_page(500, "Internal server error", + "Bad object id: %s", sha1_to_hex(sha1)); + goto cleanup; } if (obj->type == OBJ_TAG) { tag = lookup_tag(sha1); if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { - cgit_print_error(fmt("Bad tag object: %s", revname)); - return; + cgit_print_error_page(500, "Internal server error", + "Bad tag object: %s", revname); + goto cleanup; } + cgit_print_layout_start(); html("\n"); htmlf("\n"); } html("
tag name"); html_txt(revname); @@ -74,11 +81,13 @@ void cgit_print_tag(char *revname) } if (info->tagger) { html("
tagged by"); + cgit_open_filter(ctx.repo->email_filter, info->tagger_email, "tag"); html_txt(info->tagger); if (info->tagger_email && !ctx.cfg.noplainemail) { html(" "); html_txt(info->tagger_email); } + cgit_close_filter(ctx.repo->email_filter); html("
tagged object"); @@ -88,7 +97,9 @@ void cgit_print_tag(char *revname) print_download_links(revname); html("
\n"); print_tag_content(info->msg); + cgit_print_layout_end(); } else { + cgit_print_layout_start(); html("\n"); htmlf("
tag name"); html_txt(revname); @@ -99,6 +110,9 @@ void cgit_print_tag(char *revname) if (ctx.repo->snapshots) print_download_links(revname); html("
\n"); - } - return; + cgit_print_layout_end(); + } + +cleanup: + strbuf_release(&fullref); }