about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cmd.c2
-rw-r--r--ui-tree.c23
2 files changed, 19 insertions, 6 deletions
diff --git a/cmd.c b/cmd.c index 54961d9..3c90d0b 100644 --- a/cmd.c +++ b/cmd.c
@@ -172,7 +172,7 @@ struct cgit_cmd *cgit_get_cmd(void)
172 def_cmd(stats, 1, 0, 1, 0), 172 def_cmd(stats, 1, 0, 1, 0),
173 def_cmd(summary, 1, 0, 0, 0), 173 def_cmd(summary, 1, 0, 0, 0),
174 def_cmd(tag, 1, 0, 0, 0), 174 def_cmd(tag, 1, 0, 0, 0),
175 def_cmd(tree, 1, 1, 1, 0), 175 def_cmd(tree, 1, 0, 1, 0),
176 }; 176 };
177 int i; 177 int i;
178 178
diff --git a/ui-tree.c b/ui-tree.c index 2dbe89e..1b310d5 100644 --- a/ui-tree.c +++ b/ui-tree.c
@@ -92,16 +92,19 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
92 92
93 type = sha1_object_info(sha1, &size); 93 type = sha1_object_info(sha1, &size);
94 if (type == OBJ_BAD) { 94 if (type == OBJ_BAD) {
95 cgit_print_error("Bad object name: %s", sha1_to_hex(sha1)); 95 cgit_print_error_page(404, "Not found",
96 "Bad object name: %s", sha1_to_hex(sha1));
96 return; 97 return;
97 } 98 }
98 99
99 buf = read_sha1_file(sha1, &type, &size); 100 buf = read_sha1_file(sha1, &type, &size);
100 if (!buf) { 101 if (!buf) {
101 cgit_print_error("Error reading object %s", sha1_to_hex(sha1)); 102 cgit_print_error_page(500, "Internal server error",
103 "Error reading object %s", sha1_to_hex(sha1));
102 return; 104 return;
103 } 105 }
104 106
107 cgit_print_layout_start();
105 htmlf("blob: %s (", sha1_to_hex(sha1)); 108 htmlf("blob: %s (", sha1_to_hex(sha1));
106 cgit_plain_link("plain", NULL, NULL, ctx.qry.head, 109 cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
107 rev, path); 110 rev, path);
@@ -181,6 +184,7 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
181 184
182static void ls_head(void) 185static void ls_head(void)
183{ 186{
187 cgit_print_layout_start();
184 html("<table summary='tree listing' class='list'>\n"); 188 html("<table summary='tree listing' class='list'>\n");
185 html("<tr class='nohover'>"); 189 html("<tr class='nohover'>");
186 html("<th class='left'>Mode</th>"); 190 html("<th class='left'>Mode</th>");
@@ -193,6 +197,7 @@ static void ls_head(void)
193static void ls_tail(void) 197static void ls_tail(void)
194{ 198{
195 html("</table>\n"); 199 html("</table>\n");
200 cgit_print_layout_end();
196} 201}
197 202
198static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_context *walk_tree_ctx) 203static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_context *walk_tree_ctx)
@@ -204,7 +209,8 @@ static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_cont
204 209
205 tree = parse_tree_indirect(sha1); 210 tree = parse_tree_indirect(sha1);
206 if (!tree) { 211 if (!tree) {
207 cgit_print_error("Not a tree object: %s", sha1_to_hex(sha1)); 212 cgit_print_error_page(404, "Not found",
213 "Not a tree object: %s", sha1_to_hex(sha1));
208 return; 214 return;
209 } 215 }
210 216
@@ -231,6 +237,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
231 ls_head(); 237 ls_head();
232 return READ_TREE_RECURSIVE; 238 return READ_TREE_RECURSIVE;
233 } else { 239 } else {
240 walk_tree_ctx->state = 2;
234 print_object(sha1, buffer, pathname, walk_tree_ctx->curr_rev); 241 print_object(sha1, buffer, pathname, walk_tree_ctx->curr_rev);
235 return 0; 242 return 0;
236 } 243 }
@@ -265,12 +272,14 @@ void cgit_print_tree(const char *rev, char *path)
265 rev = ctx.qry.head; 272 rev = ctx.qry.head;
266 273
267 if (get_sha1(rev, sha1)) { 274 if (get_sha1(rev, sha1)) {
268 cgit_print_error("Invalid revision name: %s", rev); 275 cgit_print_error_page(404, "Not found",
276 "Invalid revision name: %s", rev);
269 return; 277 return;
270 } 278 }
271 commit = lookup_commit_reference(sha1); 279 commit = lookup_commit_reference(sha1);
272 if (!commit || parse_commit(commit)) { 280 if (!commit || parse_commit(commit)) {
273 cgit_print_error("Invalid commit reference: %s", rev); 281 cgit_print_error_page(404, "Not found",
282 "Invalid commit reference: %s", rev);
274 return; 283 return;
275 } 284 }
276 285
@@ -284,6 +293,10 @@ void cgit_print_tree(const char *rev, char *path)
284 read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); 293 read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
285 if (walk_tree_ctx.state == 1) 294 if (walk_tree_ctx.state == 1)
286 ls_tail(); 295 ls_tail();
296 else if (walk_tree_ctx.state == 2)
297 cgit_print_layout_end();
298 else
299 cgit_print_error_page(404, "Not found", "Path not found");
287 300
288cleanup: 301cleanup:
289 free(walk_tree_ctx.curr_rev); 302 free(walk_tree_ctx.curr_rev);