tree: allow lookup_tree to handle arbitrary repositories

Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Jun 28, 2018 at 18:22 UTC f58a6cb60222d32063437ae85859e6e7ac7ffc8e
2 files changed +6 -7
tree.c
+5 -5
@@ -195,13 +195,13 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match,
195 return 0;
196 }
197
198 -struct tree *lookup_tree_the_repository(const struct object_id *oid)
198 +struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
199 {
200 - struct object *obj = lookup_object(the_repository, oid->hash);
200 + struct object *obj = lookup_object(r, oid->hash);
201 if (!obj)
202 - return create_object(the_repository, oid->hash,
203 - alloc_tree_node(the_repository));
204 - return object_as_type(the_repository, obj, OBJ_TREE, 0);
202 + return create_object(r, oid->hash,
203 + alloc_tree_node(r));
204 + return object_as_type(r, obj, OBJ_TREE, 0);
205 }
206
207 int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
tree.h
+1 -2
@@ -12,8 +12,7 @@ struct tree {
12 unsigned long size;
13 };
14
15 -#define lookup_tree(r, oid) lookup_tree_##r(oid)
16 -struct tree *lookup_tree_the_repository(const struct object_id *oid);
15 +struct tree *lookup_tree(struct repository *r, const struct object_id *oid);
16
17 int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
18