Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
List the root of the tree through the shared walk
A root tree that cannot be read now lists empty rather than answering 404, the way a folder below it already does.
Diffstat (limited to 'source')
-rw-r--r--source/ui-tree.c26
1 file changed, 4 insertions, 22 deletions
diff --git a/source/ui-tree.c b/source/ui-tree.c
index 43de1bf..b80aeca 100644
--- a/source/ui-tree.c
+++ b/source/ui-tree.c
@@ -436,25 +436,6 @@ static void ls_tail(void)
cgit_print_layout_end();
}
-static void ls_tree(const struct object_id *oid, struct walk_tree_context *walk)
-{
- struct tree *tree;
- struct pathspec paths = {
- .nr = 0
- };
-
- tree = parse_tree_indirect(oid);
- if (!tree) {
- cgit_print_error_page(404, "Not Found", "Not a tree object: %s", oid_to_hex(oid));
- return;
- }
-
- ls_head();
- read_tree(the_repository, tree, &paths, ls_item, walk);
- ls_flush(walk);
- ls_tail();
-}
-
static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, void *data)
{
@@ -527,9 +508,11 @@ void cgit_print_tree(const char *rev, char *path)
walk.rev = xstrdup(rev);
if (!path) {
+ // The walk is never handed an entry for the top of the tree
+ // itself, so the listing it would have opened is opened here.
cgit_prefix_title("tree");
- ls_tree(get_commit_tree_oid(commit), &walk);
- goto cleanup;
+ walk.state = WALK_LISTING;
+ ls_head();
}
read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk);
@@ -544,6 +527,5 @@ void cgit_print_tree(const char *rev, char *path)
// WALK_ERROR_SHOWN is left alone, since the error page print_object
// put out is already complete.
-cleanup:
free(walk.rev);
}