author | Lars Hjemli <hjemli@gmail.com> | 2007-10-25 08:28:15 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-10-27 07:34:15 (UTC) |
commit | 502d71072a813e6fadb2e59fb47c2782b542674a (patch) (unidiff) | |
tree | af9dcb7521700b7a87c909e8d29093a716eb8277 | |
parent | 0c1ebce2042e69569d99551d7749b97b4e579609 (diff) | |
download | cgit-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>
-rw-r--r-- | ui-summary.c | 36 |
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 | |||
@@ -51,27 +51,19 @@ static void print_tag_header() | |||
51 | } | 51 | } |
52 | 52 | ||
53 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | 53 | static int print_tag(struct refinfo *ref) |
54 | int flags, void *cb_data) | ||
55 | { | 54 | { |
56 | struct tag *tag; | 55 | struct tag *tag; |
57 | struct taginfo *info; | 56 | struct taginfo *info; |
58 | struct object *obj; | 57 | char *url, *name = (char *)ref->refname; |
59 | char buf[256], *url; | ||
60 | 58 | ||
61 | strncpy(buf, refname, sizeof(buf)); | 59 | if (ref->object->type == OBJ_TAG) { |
62 | obj = parse_object(sha1); | 60 | tag = lookup_tag(ref->object->sha1); |
63 | if (!obj) | ||
64 | return 1; | ||
65 | if (obj->type == OBJ_TAG) { | ||
66 | tag = lookup_tag(sha1); | ||
67 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 61 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
68 | return 2; | 62 | return 2; |
69 | if (!header) | ||
70 | print_tag_header(); | ||
71 | html("<tr><td>"); | 63 | html("<tr><td>"); |
72 | url = cgit_pageurl(cgit_query_repo, "tag", | 64 | url = cgit_pageurl(cgit_query_repo, "tag", |
73 | fmt("id=%s", refname)); | 65 | fmt("id=%s", name)); |
74 | html_link_open(url, NULL, NULL); | 66 | html_link_open(url, NULL, NULL); |
75 | html_txt(buf); | 67 | html_txt(name); |
76 | html_link_close(); | 68 | html_link_close(); |
77 | html("</td><td>"); | 69 | html("</td><td>"); |
@@ -88,7 +80,7 @@ static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | |||
88 | print_tag_header(); | 80 | print_tag_header(); |
89 | html("<tr><td>"); | 81 | html("<tr><td>"); |
90 | html_txt(buf); | 82 | html_txt(name); |
91 | html("</td><td colspan='2'/><td>"); | 83 | html("</td><td colspan='2'/><td>"); |
92 | cgit_object_link(obj); | 84 | cgit_object_link(ref->object); |
93 | html("</td></tr>\n"); | 85 | html("</td></tr>\n"); |
94 | } | 86 | } |
@@ -156,6 +148,16 @@ static void cgit_print_branches() | |||
156 | static void cgit_print_tags() | 148 | static void cgit_print_tags() |
157 | { | 149 | { |
150 | struct reflist list; | ||
151 | int i; | ||
152 | |||
158 | header = 0; | 153 | header = 0; |
159 | for_each_tag_ref(cgit_print_tag_cb, NULL); | 154 | list.refs = NULL; |
155 | list.alloc = list.count = 0; | ||
156 | for_each_tag_ref(cgit_refs_cb, &list); | ||
157 | if (list.count == 0) | ||
158 | return; | ||
159 | print_tag_header(); | ||
160 | for(i=0; i<list.count; i++) | ||
161 | print_tag(list.refs[i]); | ||
160 | } | 162 | } |
161 | 163 | ||