summaryrefslogtreecommitdiffabout
path: root/ui-summary.c
authorLars Hjemli <hjemli@gmail.com>2007-10-25 08:28:15 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-10-27 07:34:15 (UTC)
commit502d71072a813e6fadb2e59fb47c2782b542674a (patch) (side-by-side diff)
treeaf9dcb7521700b7a87c909e8d29093a716eb8277 /ui-summary.c
parent0c1ebce2042e69569d99551d7749b97b4e579609 (diff)
downloadcgit-502d71072a813e6fadb2e59fb47c2782b542674a.zip
cgit-502d71072a813e6fadb2e59fb47c2782b542674a.tar.gz
cgit-502d71072a813e6fadb2e59fb47c2782b542674a.tar.bz2
Use reflist to print tag info
This updates ui-summary.c to use a reflist instead of for_each_tag_ref(), as a step towards more flexible tag handling (filtering/sorting). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-summary.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-summary.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 1e895a6..c684628 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -52,4 +52,3 @@ static void print_tag_header()
-static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1,
- int flags, void *cb_data)
+static int print_tag(struct refinfo *ref)
{
@@ -57,20 +56,13 @@ static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1,
struct taginfo *info;
- struct object *obj;
- char buf[256], *url;
+ char *url, *name = (char *)ref->refname;
- strncpy(buf, refname, sizeof(buf));
- obj = parse_object(sha1);
- if (!obj)
- return 1;
- if (obj->type == OBJ_TAG) {
- tag = lookup_tag(sha1);
+ if (ref->object->type == OBJ_TAG) {
+ tag = lookup_tag(ref->object->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", refname));
+ fmt("id=%s", name));
html_link_open(url, NULL, NULL);
- html_txt(buf);
+ html_txt(name);
html_link_close();
@@ -89,5 +81,5 @@ static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1,
html("<tr><td>");
- html_txt(buf);
+ html_txt(name);
html("</td><td colspan='2'/><td>");
- cgit_object_link(obj);
+ cgit_object_link(ref->object);
html("</td></tr>\n");
@@ -157,4 +149,14 @@ static void cgit_print_tags()
{
+ struct reflist list;
+ int i;
+
header = 0;
- for_each_tag_ref(cgit_print_tag_cb, NULL);
+ 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]);
}