From 4e9107abfe8d3edff17826875b417bcf40dc7390 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sun, 22 Jul 2007 23:42:55 +0200 Subject: Add ui-tag.c This file implements the tag-command, i.e. printing of annotated tags. Signed-off-by: Lars Hjemli Signed-off-by: Lars Hjemli --- ui-shared.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ui-shared.c') 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, html(""); } +void cgit_object_link(struct object *obj) +{ + char *page, *arg, *url; + + if (obj->type == OBJ_COMMIT) { + cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, + cgit_query_head, sha1_to_hex(obj->sha1)); + return; + } else if (obj->type == OBJ_TREE) { + page = "tree"; + arg = "id"; + } else { + page = "blob"; + arg = "id"; + } + + url = cgit_pageurl(cgit_query_repo, page, + fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); + html_link_open(url, NULL, NULL); + htmlf("%s %s", typename(obj->type), + sha1_to_hex(obj->sha1)); + html_link_close(); +} + void cgit_print_date(time_t secs, char *format) { char buf[64]; -- cgit v1.2.3-59-g8ed1b