| -rw-r--r-- | ui-summary.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/ui-summary.c b/ui-summary.c index c684628..1e895a6 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -50,21 +50,29 @@ static void print_tag_header() header = 1; } -static int print_tag(struct refinfo *ref) +static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, + int flags, void *cb_data) { struct tag *tag; struct taginfo *info; - char *url, *name = (char *)ref->refname; + struct object *obj; + char buf[256], *url; - if (ref->object->type == OBJ_TAG) { - tag = lookup_tag(ref->object->sha1); + strncpy(buf, refname, sizeof(buf)); + obj = parse_object(sha1); + if (!obj) + return 1; + if (obj->type == OBJ_TAG) { + tag = lookup_tag(sha1); if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) return 2; + if (!header) + print_tag_header(); html("<tr><td>"); url = cgit_pageurl(cgit_query_repo, "tag", - fmt("id=%s", name)); + fmt("id=%s", refname)); html_link_open(url, NULL, NULL); - html_txt(name); + html_txt(buf); html_link_close(); html("</td><td>"); if (info->tagger_date > 0) @@ -79,9 +87,9 @@ static int print_tag(struct refinfo *ref) if (!header) print_tag_header(); html("<tr><td>"); - html_txt(name); + html_txt(buf); html("</td><td colspan='2'/><td>"); - cgit_object_link(ref->object); + cgit_object_link(obj); html("</td></tr>\n"); } return 0; @@ -147,18 +155,8 @@ static void cgit_print_branches() static void cgit_print_tags() { - struct reflist list; - int i; - header = 0; - list.refs = NULL; - list.alloc = list.count = 0; - for_each_tag_ref(cgit_refs_cb, &list); - if (list.count == 0) - return; - print_tag_header(); - for(i=0; i<list.count; i++) - print_tag(list.refs[i]); + for_each_tag_ref(cgit_print_tag_cb, NULL); } static void cgit_print_archives() |