aboutsummaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2026-01-09 22:30:13 +0100
committerJunio C Hamano <gitster@pobox.com>2026-01-09 18:36:16 -0800
commit2b74f68ca0553afcab3bed4b6971cf3bfd1fa7b2 (patch)
tree7ba37140ec926df19316374e103b30daac3b3511 /tree.c
parente691395365b871608551bfbe20982b53140a50f0 (diff)
downloadgit-2b74f68ca0553afcab3bed4b6971cf3bfd1fa7b2.tar.xz
tree: add repo_parse_tree*()
Add variants of parse_tree(), parse_tree_gently() and parse_tree_indirect() that allow using an arbitrary repository. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/tree.c b/tree.c
index 2a677234d6..036f56ca29 100644
--- a/tree.c
+++ b/tree.c
@@ -187,14 +187,19 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
int parse_tree_gently(struct tree *item, int quiet_on_missing)
{
+ return repo_parse_tree_gently(the_repository, item, quiet_on_missing);
+}
+
+int repo_parse_tree_gently(struct repository *r, struct tree *item,
+ int quiet_on_missing)
+{
enum object_type type;
void *buffer;
unsigned long size;
if (item->object.parsed)
return 0;
- buffer = odb_read_object(the_repository->objects, &item->object.oid,
- &type, &size);
+ buffer = odb_read_object(r->objects, &item->object.oid, &type, &size);
if (!buffer)
return quiet_on_missing ? -1 :
error("Could not read %s",
@@ -216,7 +221,12 @@ void free_tree_buffer(struct tree *tree)
struct tree *parse_tree_indirect(const struct object_id *oid)
{
- struct repository *r = the_repository;
+ return repo_parse_tree_indirect(the_repository, oid);
+}
+
+struct tree *repo_parse_tree_indirect(struct repository *r,
+ const struct object_id *oid)
+{
struct object *obj = parse_object(r, oid);
return (struct tree *)repo_peel_to_type(r, NULL, 0, obj, OBJ_TREE);
}