diff options
author | Lukas Fleischer | 2013-04-06 23:39:08 +0200 |
---|---|---|
committer | Jason A. Donenfeld | 2013-04-08 15:45:34 +0200 |
commit | 4b4a62d507adc61e20e75e2748301ef307a6c95f (patch) | |
tree | 36846dbdab0e714db54d9f6949ee0a605046b87c /ui-refs.c | |
parent | caca860ba79fe9f6bc387f64ddb57ac0db1fac33 (diff) | |
download | cgit-4b4a62d507adc61e20e75e2748301ef307a6c95f.tar.gz cgit-4b4a62d507adc61e20e75e2748301ef307a6c95f.tar.bz2 cgit-4b4a62d507adc61e20e75e2748301ef307a6c95f.zip |
ui-refs.c: Refactor print_tag()
The code snippets for OBJ_TAG and other object types are almost
equivalent. Merge them and use a couple of inline if conditions to
select proper fields.
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'ui-refs.c')
-rw-r--r-- | ui-refs.c | 56 |
1 files changed, 27 insertions, 29 deletions
@@ -127,47 +127,45 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) | |||
127 | if (free_ref) | 127 | if (free_ref) |
128 | free((char *)ref); | 128 | free((char *)ref); |
129 | } | 129 | } |
130 | |||
130 | static int print_tag(struct refinfo *ref) | 131 | static int print_tag(struct refinfo *ref) |
131 | { | 132 | { |
132 | struct tag *tag; | 133 | struct tag *tag = NULL; |
133 | struct taginfo *info; | 134 | struct taginfo *info = NULL; |
134 | char *name = (char *)ref->refname; | 135 | char *name = (char *)ref->refname; |
136 | struct object *obj = ref->object; | ||
135 | 137 | ||
136 | if (ref->object->type == OBJ_TAG) { | 138 | if (obj->type == OBJ_TAG) { |
137 | tag = (struct tag *)ref->object; | 139 | tag = (struct tag *)obj; |
140 | obj = tag->tagged; | ||
138 | info = ref->tag; | 141 | info = ref->tag; |
139 | if (!tag || !info) | 142 | if (!tag || !info) |
140 | return 1; | 143 | return 1; |
141 | html("<tr><td>"); | 144 | } |
142 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); | 145 | |
143 | html("</td><td>"); | 146 | html("<tr><td>"); |
144 | if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT)) | 147 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); |
145 | print_tag_downloads(ctx.repo, name); | 148 | html("</td><td>"); |
146 | else | 149 | if (ctx.repo->snapshots && (obj->type == OBJ_COMMIT)) |
147 | cgit_object_link(tag->tagged); | 150 | print_tag_downloads(ctx.repo, name); |
148 | html("</td><td>"); | 151 | else |
152 | cgit_object_link(obj); | ||
153 | html("</td><td>"); | ||
154 | if (info) { | ||
149 | if (info->tagger) | 155 | if (info->tagger) |
150 | html(info->tagger); | 156 | html(info->tagger); |
151 | html("</td><td colspan='2'>"); | 157 | } else if (ref->object->type == OBJ_COMMIT) { |
158 | html(ref->commit->author); | ||
159 | } | ||
160 | html("</td><td colspan='2'>"); | ||
161 | if (info) { | ||
152 | if (info->tagger_date > 0) | 162 | if (info->tagger_date > 0) |
153 | cgit_print_age(info->tagger_date, -1, NULL); | 163 | cgit_print_age(info->tagger_date, -1, NULL); |
154 | html("</td></tr>\n"); | 164 | } else if (ref->object->type == OBJ_COMMIT) { |
155 | } else { | 165 | cgit_print_age(ref->commit->commit->date, -1, NULL); |
156 | html("<tr><td>"); | ||
157 | cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); | ||
158 | html("</td><td>"); | ||
159 | if (ctx.repo->snapshots && (ref->object->type == OBJ_COMMIT)) | ||
160 | print_tag_downloads(ctx.repo, name); | ||
161 | else | ||
162 | cgit_object_link(ref->object); | ||
163 | html("</td><td>"); | ||
164 | if (ref->object->type == OBJ_COMMIT) | ||
165 | html(ref->commit->author); | ||
166 | html("</td><td colspan='2'>"); | ||
167 | if (ref->object->type == OBJ_COMMIT) | ||
168 | cgit_print_age(ref->commit->commit->date, -1, NULL); | ||
169 | html("</td></tr>\n"); | ||
170 | } | 166 | } |
167 | html("</td></tr>\n"); | ||
168 | |||
171 | return 0; | 169 | return 0; |
172 | } | 170 | } |
173 | 171 | ||