diff options
author | John Keeping | 2015-08-14 12:47:19 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2015-08-14 15:46:51 +0200 |
commit | 696a33b66f8638d5c3e0464d66760c6d60ff24a5 (patch) | |
tree | 8da0938fb4cc6ac6dc487dfc9a117cc1f910de3e /ui-tag.c | |
parent | a3daa41b78fc2c528c9a42630ab95451ddb87358 (diff) | |
download | cgit-696a33b66f8638d5c3e0464d66760c6d60ff24a5.tar.gz cgit-696a33b66f8638d5c3e0464d66760c6d60ff24a5.tar.bz2 cgit-696a33b66f8638d5c3e0464d66760c6d60ff24a5.zip |
tag: move layout into page function
This also allows us to return proper HTTP error codes when something
goes wrong.
Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-tag.c')
-rw-r--r-- | ui-tag.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -52,20 +52,24 @@ void cgit_print_tag(char *revname) | |||
52 | 52 | ||
53 | strbuf_addf(&fullref, "refs/tags/%s", revname); | 53 | strbuf_addf(&fullref, "refs/tags/%s", revname); |
54 | if (get_sha1(fullref.buf, sha1)) { | 54 | if (get_sha1(fullref.buf, sha1)) { |
55 | cgit_print_error("Bad tag reference: %s", revname); | 55 | cgit_print_error_page(404, "Not found", |
56 | "Bad tag reference: %s", revname); | ||
56 | goto cleanup; | 57 | goto cleanup; |
57 | } | 58 | } |
58 | obj = parse_object(sha1); | 59 | obj = parse_object(sha1); |
59 | if (!obj) { | 60 | if (!obj) { |
60 | cgit_print_error("Bad object id: %s", sha1_to_hex(sha1)); | 61 | cgit_print_error_page(500, "Internal server error", |
62 | "Bad object id: %s", sha1_to_hex(sha1)); | ||
61 | goto cleanup; | 63 | goto cleanup; |
62 | } | 64 | } |
63 | if (obj->type == OBJ_TAG) { | 65 | if (obj->type == OBJ_TAG) { |
64 | tag = lookup_tag(sha1); | 66 | tag = lookup_tag(sha1); |
65 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { | 67 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { |
66 | cgit_print_error("Bad tag object: %s", revname); | 68 | cgit_print_error_page(500, "Internal server error", |
69 | "Bad tag object: %s", revname); | ||
67 | goto cleanup; | 70 | goto cleanup; |
68 | } | 71 | } |
72 | cgit_print_layout_start(); | ||
69 | html("<table class='commit-info'>\n"); | 73 | html("<table class='commit-info'>\n"); |
70 | htmlf("<tr><td>tag name</td><td>"); | 74 | htmlf("<tr><td>tag name</td><td>"); |
71 | html_txt(revname); | 75 | html_txt(revname); |
@@ -93,7 +97,9 @@ void cgit_print_tag(char *revname) | |||
93 | print_download_links(revname); | 97 | print_download_links(revname); |
94 | html("</table>\n"); | 98 | html("</table>\n"); |
95 | print_tag_content(info->msg); | 99 | print_tag_content(info->msg); |
100 | cgit_print_layout_end(); | ||
96 | } else { | 101 | } else { |
102 | cgit_print_layout_start(); | ||
97 | html("<table class='commit-info'>\n"); | 103 | html("<table class='commit-info'>\n"); |
98 | htmlf("<tr><td>tag name</td><td>"); | 104 | htmlf("<tr><td>tag name</td><td>"); |
99 | html_txt(revname); | 105 | html_txt(revname); |
@@ -104,6 +110,7 @@ void cgit_print_tag(char *revname) | |||
104 | if (ctx.repo->snapshots) | 110 | if (ctx.repo->snapshots) |
105 | print_download_links(revname); | 111 | print_download_links(revname); |
106 | html("</table>\n"); | 112 | html("</table>\n"); |
113 | cgit_print_layout_end(); | ||
107 | } | 114 | } |
108 | 115 | ||
109 | cleanup: | 116 | cleanup: |