|
diff --git a/ui-tree.c b/ui-tree.c index f53ab64..a164767 100644 --- a/ ui-tree.c+++ b/ ui-tree.c |
|
@@ -235,51 +235,51 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen, |
235 | state = 1; |
235 | state = 1; |
236 | ls_head(); |
236 | ls_head(); |
237 | return READ_TREE_RECURSIVE; |
237 | return READ_TREE_RECURSIVE; |
238 | } else { |
238 | } else { |
239 | print_object(sha1, buffer, pathname); |
239 | print_object(sha1, buffer, pathname); |
240 | return 0; |
240 | return 0; |
241 | } |
241 | } |
242 | } |
242 | } |
243 | ls_item(sha1, base, baselen, pathname, mode, stage, NULL); |
243 | ls_item(sha1, base, baselen, pathname, mode, stage, NULL); |
244 | return 0; |
244 | return 0; |
245 | } |
245 | } |
246 | |
246 | |
247 | |
247 | |
248 | /* |
248 | /* |
249 | * Show a tree or a blob |
249 | * Show a tree or a blob |
250 | * rev: the commit pointing at the root tree object |
250 | * rev: the commit pointing at the root tree object |
251 | * path: path to tree or blob |
251 | * path: path to tree or blob |
252 | */ |
252 | */ |
253 | void cgit_print_tree(const char *rev, char *path) |
253 | void cgit_print_tree(const char *rev, char *path) |
254 | { |
254 | { |
255 | unsigned char sha1[20]; |
255 | unsigned char sha1[20]; |
256 | struct commit *commit; |
256 | struct commit *commit; |
257 | const char *paths[] = {path, NULL}; |
257 | const char *paths[] = {path, NULL}; |
258 | |
258 | |
259 | if (!rev) |
259 | if (!rev) |
260 | rev = ctx.qry.head; |
260 | rev = ctx.qry.head; |
261 | |
261 | |
262 | curr_rev = xstrdup(rev); |
262 | curr_rev = xstrdup(rev); |
263 | if (get_sha1(rev, sha1)) { |
263 | if (get_sha1(rev, sha1)) { |
264 | cgit_print_error(fmt("Invalid revision name: %s", rev)); |
264 | cgit_print_error(fmt("Invalid revision name: %s", rev)); |
265 | return; |
265 | return; |
266 | } |
266 | } |
267 | commit = lookup_commit_reference(sha1); |
267 | commit = lookup_commit_reference(sha1); |
268 | if (!commit || parse_commit(commit)) { |
268 | if (!commit || parse_commit(commit)) { |
269 | cgit_print_error(fmt("Invalid commit reference: %s", rev)); |
269 | cgit_print_error(fmt("Invalid commit reference: %s", rev)); |
270 | return; |
270 | return; |
271 | } |
271 | } |
272 | |
272 | |
273 | html("path: <a href='"); |
273 | html("path: <a href='"); |
274 | html_attr(cgit_pageurl(ctx.qry.repo, "tree", fmt("h=%s", rev))); |
274 | html_attr(cgit_pageurl(ctx.qry.repo, "tree", fmt("h=%s", rev))); |
275 | html("'>root</a>"); |
275 | html("'>root</a>"); |
276 | |
276 | |
277 | if (path == NULL) { |
277 | if (path == NULL) { |
278 | ls_tree(commit->tree->object.sha1, NULL); |
278 | ls_tree(commit->tree->object.sha1, NULL); |
279 | return; |
279 | return; |
280 | } |
280 | } |
281 | |
281 | |
282 | match_path = path; |
282 | match_path = path; |
283 | read_tree_recursive(commit->tree, NULL, 0, 0, paths, walk_tree, NULL); |
283 | read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL); |
284 | ls_tail(); |
284 | ls_tail(); |
285 | } |
285 | } |
|