aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Keeping2015-08-14 12:47:13 +0100
committerJason A. Donenfeld2015-08-14 15:46:51 +0200
commitc53a15c77a6763b4d6fefb033923ba7493b884a2 (patch)
treef4fe41b929428f3c13b283a4ad57b36f90c36add
parent51d9176e4bb5c619481355c6b895c6dec30c4f82 (diff)
downloadcgit-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>
-rw-r--r--cmd.c2
-rw-r--r--ui-commit.c8
2 files changed, 7 insertions, 3 deletions
diff --git a/cmd.c b/cmd.c
index 616890c..1b42a47 100644
--- a/cmd.c
+++ b/cmd.c
@@ -157,7 +157,7 @@ struct cgit_cmd *cgit_get_cmd(void)
157 def_cmd(atom, 1, 0, 0, 0), 157 def_cmd(atom, 1, 0, 0, 0),
158 def_cmp(about, 0, 0, 0, 0), 158 def_cmp(about, 0, 0, 0, 0),
159 def_cmd(blob, 1, 0, 0, 0), 159 def_cmd(blob, 1, 0, 0, 0),
160 def_cmd(commit, 1, 1, 1, 0), 160 def_cmd(commit, 1, 0, 1, 0),
161 def_cmd(diff, 1, 1, 1, 0), 161 def_cmd(diff, 1, 1, 1, 0),
162 def_cmd(info, 1, 0, 0, 1), 162 def_cmd(info, 1, 0, 0, 1),
163 def_cmd(log, 1, 1, 1, 0), 163 def_cmd(log, 1, 1, 1, 0),
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(&notes); 143 strbuf_release(&notes);
141 cgit_free_commitinfo(info); 144 cgit_free_commitinfo(info);
145 cgit_print_layout_end();
142} 146}