]> git.cameronkatri.com Git - cgit.git/blobdiff - ui-tree.c
git: update to v2.32.0
[cgit.git] / ui-tree.c
index e6b3074faa964e7051674bdf75adcf7dfe85c262..b61f6f5433976202ea277bfa7bf5fd9aed4c4808 100644 (file)
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -84,7 +84,7 @@ static void print_binary_buffer(char *buf, unsigned long size)
        html("</table>\n");
 }
 
-static void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev)
+static void print_object(const struct object_id *oid, const char *path, const char *basename, const char *rev)
 {
        enum object_type type;
        char *buf;
@@ -110,7 +110,7 @@ static void print_object(const struct object_id *oid, char *path, const char *ba
        htmlf("blob: %s (", oid_to_hex(oid));
        cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
                        rev, path);
-       if (ctx.cfg.enable_blame) {
+       if (ctx.repo->enable_blame) {
                html(") (");
                cgit_blame_link("blame", NULL, NULL, ctx.qry.head,
                                rev, path);
@@ -139,8 +139,7 @@ struct single_tree_ctx {
 };
 
 static int single_tree_cb(const struct object_id *oid, struct strbuf *base,
-                         const char *pathname, unsigned mode, int stage,
-                         void *cbdata)
+                         const char *pathname, unsigned mode, void *cbdata)
 {
        struct single_tree_ctx *ctx = cbdata;
 
@@ -177,7 +176,7 @@ static void write_tree_link(const struct object_id *oid, char *name,
                cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev,
                               fullpath->buf);
 
-               tree = lookup_tree(&tree_ctx.oid);
+               tree = lookup_tree(the_repository, &tree_ctx.oid);
                if (!tree)
                        return;
 
@@ -185,8 +184,7 @@ static void write_tree_link(const struct object_id *oid, char *name,
                tree_ctx.name = NULL;
                tree_ctx.count = 0;
 
-               read_tree_recursive(tree, "", 0, 1, &paths, single_tree_cb,
-                                   &tree_ctx);
+               read_tree(the_repository, tree, &paths, single_tree_cb, &tree_ctx);
 
                if (tree_ctx.count != 1)
                        break;
@@ -199,7 +197,7 @@ static void write_tree_link(const struct object_id *oid, char *name,
 }
 
 static int ls_item(const struct object_id *oid, struct strbuf *base,
-               const char *pathname, unsigned mode, int stage, void *cbdata)
+               const char *pathname, unsigned mode, void *cbdata)
 {
        struct walk_tree_context *walk_tree_ctx = cbdata;
        char *name;
@@ -251,7 +249,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,
        if (!S_ISGITLINK(mode))
                cgit_plain_link("plain", NULL, "button", ctx.qry.head,
                                walk_tree_ctx->curr_rev, fullpath.buf);
-       if (!S_ISDIR(mode) && ctx.cfg.enable_blame)
+       if (!S_ISDIR(mode) && ctx.repo->enable_blame)
                cgit_blame_link("blame", NULL, "button", ctx.qry.head,
                                walk_tree_ctx->curr_rev, fullpath.buf);
        html("</td></tr>\n");
@@ -279,7 +277,7 @@ static void ls_tail(void)
        cgit_print_layout_end();
 }
 
-static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_context *walk_tree_ctx)
+static void ls_tree(const struct object_id *oid, const char *path, struct walk_tree_context *walk_tree_ctx)
 {
        struct tree *tree;
        struct pathspec paths = {
@@ -294,13 +292,13 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co
        }
 
        ls_head();
-       read_tree_recursive(tree, "", 0, 1, &paths, ls_item, walk_tree_ctx);
+       read_tree(the_repository, tree, &paths, ls_item, walk_tree_ctx);
        ls_tail();
 }
 
 
 static int walk_tree(const struct object_id *oid, struct strbuf *base,
-               const char *pathname, unsigned mode, int stage, void *cbdata)
+               const char *pathname, unsigned mode, void *cbdata)
 {
        struct walk_tree_context *walk_tree_ctx = cbdata;
 
@@ -325,7 +323,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base,
                        return 0;
                }
        }
-       ls_item(oid, base, pathname, mode, stage, walk_tree_ctx);
+       ls_item(oid, base, pathname, mode, walk_tree_ctx);
        return 0;
 }
 
@@ -359,7 +357,7 @@ void cgit_print_tree(const char *rev, char *path)
                        "Invalid revision name: %s", rev);
                return;
        }
-       commit = lookup_commit_reference(&oid);
+       commit = lookup_commit_reference(the_repository, &oid);
        if (!commit || parse_commit(commit)) {
                cgit_print_error_page(404, "Not found",
                        "Invalid commit reference: %s", rev);
@@ -369,11 +367,12 @@ void cgit_print_tree(const char *rev, char *path)
        walk_tree_ctx.curr_rev = xstrdup(rev);
 
        if (path == NULL) {
-               ls_tree(&commit->maybe_tree->object.oid, NULL, &walk_tree_ctx);
+               ls_tree(get_commit_tree_oid(commit), NULL, &walk_tree_ctx);
                goto cleanup;
        }
 
-       read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+       read_tree(the_repository, repo_get_commit_tree(the_repository, commit),
+                 &paths, walk_tree, &walk_tree_ctx);
        if (walk_tree_ctx.state == 1)
                ls_tail();
        else if (walk_tree_ctx.state == 2)