diff options
Diffstat (limited to 'ui-tag.c')
-rw-r--r-- | ui-tag.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -41,6 +41,7 @@ static void print_download_links(char *revname) | |||
41 | 41 | ||
42 | void cgit_print_tag(char *revname) | 42 | void cgit_print_tag(char *revname) |
43 | { | 43 | { |
44 | struct strbuf fullref = STRBUF_INIT; | ||
44 | unsigned char sha1[20]; | 45 | unsigned char sha1[20]; |
45 | struct object *obj; | 46 | struct object *obj; |
46 | struct tag *tag; | 47 | struct tag *tag; |
@@ -49,20 +50,21 @@ void cgit_print_tag(char *revname) | |||
49 | if (!revname) | 50 | if (!revname) |
50 | revname = ctx.qry.head; | 51 | revname = ctx.qry.head; |
51 | 52 | ||
52 | if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { | 53 | strbuf_addf(&fullref, "refs/tags/%s", revname); |
54 | if (get_sha1(fullref.buf, sha1)) { | ||
53 | cgit_print_error("Bad tag reference: %s", revname); | 55 | cgit_print_error("Bad tag reference: %s", revname); |
54 | return; | 56 | goto cleanup; |
55 | } | 57 | } |
56 | obj = parse_object(sha1); | 58 | obj = parse_object(sha1); |
57 | if (!obj) { | 59 | if (!obj) { |
58 | cgit_print_error("Bad object id: %s", sha1_to_hex(sha1)); | 60 | cgit_print_error("Bad object id: %s", sha1_to_hex(sha1)); |
59 | return; | 61 | goto cleanup; |
60 | } | 62 | } |
61 | if (obj->type == OBJ_TAG) { | 63 | if (obj->type == OBJ_TAG) { |
62 | tag = lookup_tag(sha1); | 64 | tag = lookup_tag(sha1); |
63 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { | 65 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { |
64 | cgit_print_error("Bad tag object: %s", revname); | 66 | cgit_print_error("Bad tag object: %s", revname); |
65 | return; | 67 | goto cleanup; |
66 | } | 68 | } |
67 | html("<table class='commit-info'>\n"); | 69 | html("<table class='commit-info'>\n"); |
68 | htmlf("<tr><td>tag name</td><td>"); | 70 | htmlf("<tr><td>tag name</td><td>"); |
@@ -101,5 +103,7 @@ void cgit_print_tag(char *revname) | |||
101 | print_download_links(revname); | 103 | print_download_links(revname); |
102 | html("</table>\n"); | 104 | html("</table>\n"); |
103 | } | 105 | } |
104 | return; | 106 | |
107 | cleanup: | ||
108 | strbuf_release(&fullref); | ||
105 | } | 109 | } |