diff options
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index d4376ce..fd71c12 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -218,6 +218,30 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
218 | html("</a>"); | 218 | html("</a>"); |
219 | } | 219 | } |
220 | 220 | ||
221 | void cgit_object_link(struct object *obj) | ||
222 | { | ||
223 | char *page, *arg, *url; | ||
224 | |||
225 | if (obj->type == OBJ_COMMIT) { | ||
226 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, | ||
227 | cgit_query_head, sha1_to_hex(obj->sha1)); | ||
228 | return; | ||
229 | } else if (obj->type == OBJ_TREE) { | ||
230 | page = "tree"; | ||
231 | arg = "id"; | ||
232 | } else { | ||
233 | page = "blob"; | ||
234 | arg = "id"; | ||
235 | } | ||
236 | |||
237 | url = cgit_pageurl(cgit_query_repo, page, | ||
238 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | ||
239 | html_link_open(url, NULL, NULL); | ||
240 | htmlf("%s %s", typename(obj->type), | ||
241 | sha1_to_hex(obj->sha1)); | ||
242 | html_link_close(); | ||
243 | } | ||
244 | |||
221 | void cgit_print_date(time_t secs, char *format) | 245 | void cgit_print_date(time_t secs, char *format) |
222 | { | 246 | { |
223 | char buf[64]; | 247 | char buf[64]; |