From 4e9107abfe8d3edff17826875b417bcf40dc7390 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sun, 22 Jul 2007 23:42:55 +0200 Subject: Add ui-tag.c This file implements the tag-command, i.e. printing of annotated tags. Signed-off-by: Lars Hjemli Signed-off-by: Lars Hjemli --- ui-tag.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 ui-tag.c (limited to 'ui-tag.c') diff --git a/ui-tag.c b/ui-tag.c new file mode 100644 index 0000000..a6989ff --- /dev/null +++ b/ui-tag.c @@ -0,0 +1,74 @@ +/* ui-tag.c: display a tag + * + * Copyright (C) 2007 Lars Hjemli + * + * Licensed under GNU General Public License v2 + * (see COPYING for full license text) + */ + +#include "cgit.h" + + +static void print_tag_content(char *buf) +{ + char *p; + + if (!buf) + return; + + html("
"); + p = strchr(buf, '\n'); + if (p) + *p = '\0'; + html_txt(buf); + html("
"); + if (p) { + html("
"); + html_txt(++p); + html("
"); + } +} + +void cgit_print_tag(char *revname) +{ + unsigned char sha1[20]; + struct object *obj; + struct tag *tag; + struct taginfo *info; + + if (get_sha1(revname, sha1)) { + cgit_print_error(fmt("Bad tag reference: %s", revname)); + return; + } + obj = parse_object(sha1); + if (!obj) { + cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); + return; + } + 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; + } + html("\n"); + htmlf("\n", + revname, sha1_to_hex(sha1)); + if (info->tagger_date > 0) { + html("\n"); + } + if (info->tagger) { + html("\n"); + } + html("\n"); + html("
Tag name%s (%s)
Tag date"); + cgit_print_date(info->tagger_date, FMT_LONGDATE); + html("
Tagged by"); + html_txt(info->tagger); + html("
Tagged object"); + cgit_object_link(tag->tagged); + html("
\n"); + print_tag_content(info->msg); + } + return; +} -- cgit v1.2.3-54-g00ecf