X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/210a5711ad8135de025b1a058079eead3d680a67..42d5476f258e7909682f1b611da00d64507d45c6:/ui-tree.c diff --git a/ui-tree.c b/ui-tree.c index 561f9e7..aebe145 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -8,6 +8,7 @@ #include #include "cgit.h" +#include "ui-tree.h" #include "html.h" #include "ui-shared.h" @@ -94,15 +95,13 @@ static void print_object(const unsigned char *sha1, char *path, const char *base type = sha1_object_info(sha1, &size); if (type == OBJ_BAD) { - cgit_print_error(fmt("Bad object name: %s", - sha1_to_hex(sha1))); + cgit_print_error("Bad object name: %s", sha1_to_hex(sha1)); return; } buf = read_sha1_file(sha1, &type, &size); if (!buf) { - cgit_print_error(fmt("Error reading object %s", - sha1_to_hex(sha1))); + cgit_print_error("Error reading object %s", sha1_to_hex(sha1)); return; } @@ -208,8 +207,7 @@ static void ls_tree(const unsigned char *sha1, char *path, struct walk_tree_cont tree = parse_tree_indirect(sha1); if (!tree) { - cgit_print_error(fmt("Not a tree object: %s", - sha1_to_hex(sha1))); + cgit_print_error("Not a tree object: %s", sha1_to_hex(sha1)); return; } @@ -271,23 +269,27 @@ void cgit_print_tree(const char *rev, char *path) if (!rev) rev = ctx.qry.head; - walk_tree_ctx.curr_rev = xstrdup(rev); if (get_sha1(rev, sha1)) { - cgit_print_error(fmt("Invalid revision name: %s", rev)); + cgit_print_error("Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(sha1); if (!commit || parse_commit(commit)) { - cgit_print_error(fmt("Invalid commit reference: %s", rev)); + cgit_print_error("Invalid commit reference: %s", rev); return; } + walk_tree_ctx.curr_rev = xstrdup(rev); + if (path == NULL) { ls_tree(commit->tree->object.sha1, NULL, &walk_tree_ctx); - return; + goto cleanup; } read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (walk_tree_ctx.state == 1) ls_tail(); + +cleanup: + free(walk_tree_ctx.curr_rev); }