diff options
1 files changed, 41 insertions, 0 deletions
| -rw-r--r-- | ui-tree.c | 41 |
@@ -431,3 +431,44 @@ void cgit_print_tree(const char *rev, char *path) cleanup: free(walk_tree_ctx.curr_rev); } + +void cgit_print_tree_component(const char *rev, char *path) +{ + struct object_id oid; + struct commit *commit; + struct walk_tree_context walk_tree_ctx = { + .match_path = path, + .state = 0 + }; + struct tree *tree; + struct pathspec paths = { + .nr = 0 + }; + + if (!rev) + rev = ctx.qry.head; + + if (path != NULL || repo_get_oid(the_repository, rev, &oid)) + return; + + commit = lookup_commit_reference(the_repository, &oid); + if (!commit || repo_parse_commit(the_repository, commit)) + return; + + walk_tree_ctx.curr_rev = xstrdup(rev); + + tree = parse_tree_indirect(get_commit_tree_oid(commit)); + if (tree) { + html("<table summary='tree listing' class='list'>\n"); + html("<tr class='nohover'>"); + html("<th class='left'>Name</th>"); + html("<th class='right'>Size</th>"); + html("<th/>"); + html("</tr>\n"); + read_tree(the_repository, tree, &paths, ls_item, &walk_tree_ctx); + html("</table>\n"); + cgit_print_repo_readme_component(ctx.qry.path); + } + + free(walk_tree_ctx.curr_rev); +} |
