diff options
author | John Keeping | 2015-08-14 12:47:13 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2015-08-14 15:46:51 +0200 |
commit | c53a15c77a6763b4d6fefb033923ba7493b884a2 (patch) | |
tree | f4fe41b929428f3c13b283a4ad57b36f90c36add /ui-commit.c | |
parent | 51d9176e4bb5c619481355c6b895c6dec30c4f82 (diff) | |
download | cgit-c53a15c77a6763b4d6fefb033923ba7493b884a2.tar.gz cgit-c53a15c77a6763b4d6fefb033923ba7493b884a2.tar.bz2 cgit-c53a15c77a6763b4d6fefb033923ba7493b884a2.zip |
commit: move layout into page function
This allows us to return a proper HTTP status code when an object is not
found by switching from cgit_print_error() to cgit_print_error_page().
Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-commit.c')
-rw-r--r-- | ui-commit.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ui-commit.c b/ui-commit.c index d5a888d..2bca7a0 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -27,12 +27,14 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
27 | hex = ctx.qry.head; | 27 | hex = ctx.qry.head; |
28 | 28 | ||
29 | if (get_sha1(hex, sha1)) { | 29 | if (get_sha1(hex, sha1)) { |
30 | cgit_print_error("Bad object id: %s", hex); | 30 | cgit_print_error_page(400, "Bad request", |
31 | "Bad object id: %s", hex); | ||
31 | return; | 32 | return; |
32 | } | 33 | } |
33 | commit = lookup_commit_reference(sha1); | 34 | commit = lookup_commit_reference(sha1); |
34 | if (!commit) { | 35 | if (!commit) { |
35 | cgit_print_error("Bad commit reference: %s", hex); | 36 | cgit_print_error_page(404, "Not found", |
37 | "Bad commit reference: %s", hex); | ||
36 | return; | 38 | return; |
37 | } | 39 | } |
38 | info = cgit_parse_commit(commit); | 40 | info = cgit_parse_commit(commit); |
@@ -41,6 +43,7 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
41 | 43 | ||
42 | load_ref_decorations(DECORATE_FULL_REFS); | 44 | load_ref_decorations(DECORATE_FULL_REFS); |
43 | 45 | ||
46 | cgit_print_layout_start(); | ||
44 | cgit_print_diff_ctrls(); | 47 | cgit_print_diff_ctrls(); |
45 | html("<table summary='commit info' class='commit-info'>\n"); | 48 | html("<table summary='commit info' class='commit-info'>\n"); |
46 | html("<tr><th>author</th><td>"); | 49 | html("<tr><th>author</th><td>"); |
@@ -139,4 +142,5 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
139 | } | 142 | } |
140 | strbuf_release(¬es); | 143 | strbuf_release(¬es); |
141 | cgit_free_commitinfo(info); | 144 | cgit_free_commitinfo(info); |
145 | cgit_print_layout_end(); | ||
142 | } | 146 | } |