commit: allow lookup_commit 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 bacf16874e0af1a34537d814274d66ae16d4cde8
2 files changed +6 -7
commit.c
+5 -5
@@ -53,13 +53,13 @@ struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref
53 return c;
54 }
55
56 -struct commit *lookup_commit_the_repository(const struct object_id *oid)
56 +struct commit *lookup_commit(struct repository *r, const struct object_id *oid)
57 {
58 - struct object *obj = lookup_object(the_repository, oid->hash);
58 + struct object *obj = lookup_object(r, oid->hash);
59 if (!obj)
60 - return create_object(the_repository, oid->hash,
61 - alloc_commit_node(the_repository));
62 - return object_as_type(the_repository, obj, OBJ_COMMIT, 0);
60 + return create_object(r, oid->hash,
61 + alloc_commit_node(r));
62 + return object_as_type(r, obj, OBJ_COMMIT, 0);
63 }
64
65 struct commit *lookup_commit_reference_by_name(const char *name)
commit.h
+1 -2
@@ -63,8 +63,7 @@ enum decoration_type {
63 void add_name_decoration(enum decoration_type type, const char *name, struct object *obj);
64 const struct name_decoration *get_name_decoration(const struct object *obj);
65
66 -#define lookup_commit(r, o) lookup_commit_##r(o)
67 -struct commit *lookup_commit_the_repository(const struct object_id *oid);
66 +struct commit *lookup_commit(struct repository *r, const struct object_id *oid);
67 #define lookup_commit_reference(r, o) \
68 lookup_commit_reference_##r(o)
69 struct commit *lookup_commit_reference_the_repository(const struct object_id *oid);