Add a repository argument to allow callers of lookup_replace_object to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx> --- builtin/mktag.c | 2 +- object.c | 2 +- replace-object.h | 3 ++- sha1_file.c | 6 +++--- streaming.c | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index 93934e8e4b..ab41735f2a 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -26,7 +26,7 @@ static int verify_object(const unsigned char *sha1, const char *expected_type) enum object_type type; unsigned long size; void *buffer = read_sha1_file(sha1, &type, &size); - const unsigned char *repl = lookup_replace_object(sha1); + const unsigned char *repl = lookup_replace_object(the_repository, sha1); if (buffer) { if (type == type_from_string(expected_type)) diff --git a/object.c b/object.c index fc0ccbefef..a5cafb10e7 100644 --- a/object.c +++ b/object.c @@ -246,7 +246,7 @@ struct object *parse_object(const struct object_id *oid) unsigned long size; enum object_type type; int eaten; - const unsigned char *repl = lookup_replace_object(oid->hash); + const unsigned char *repl = lookup_replace_object(the_repository, oid->hash); void *buffer; struct object *obj; diff --git a/replace-object.h b/replace-object.h index 67a433d5a5..c61ee66e95 100644 --- a/replace-object.h +++ b/replace-object.h @@ -21,7 +21,8 @@ extern const unsigned char *do_lookup_replace_object(struct repository *r, const * either sha1 or a pointer to a permanently-allocated value. When * object replacement is suppressed, always return sha1. */ -static inline const unsigned char *lookup_replace_object(const unsigned char *sha1) +#define lookup_replace_object(r, s) lookup_replace_object_##r(s) +static inline const unsigned char *lookup_replace_object_the_repository(const unsigned char *sha1) { if (!check_replace_refs || (the_repository->objects.replacements.prepared && diff --git a/sha1_file.c b/sha1_file.c index 8ee86f8ede..a6df4b61c7 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1243,7 +1243,7 @@ int sha1_object_info_extended_the_repository(const unsigned char *sha1, struct o struct pack_entry e; int rtype; const unsigned char *real = (flags & OBJECT_INFO_LOOKUP_REPLACE) ? - lookup_replace_object(sha1) : + lookup_replace_object(the_repository, sha1) : sha1; if (is_null_sha1(real)) @@ -1369,8 +1369,8 @@ void *read_sha1_file_extended(const unsigned char *sha1, const struct packed_git *p; const char *path; struct stat st; - const unsigned char *repl = lookup_replace ? lookup_replace_object(sha1) - : sha1; + const unsigned char *repl = lookup_replace ? + lookup_replace_object(the_repository, sha1) : sha1; errno = 0; data = read_object(repl, type, size); diff --git a/streaming.c b/streaming.c index c47600e719..bc3c4811ca 100644 --- a/streaming.c +++ b/streaming.c @@ -140,7 +140,7 @@ struct git_istream *open_istream(const unsigned char *sha1, { struct git_istream *st; struct object_info oi = OBJECT_INFO_INIT; - const unsigned char *real = lookup_replace_object(sha1); + const unsigned char *real = lookup_replace_object(the_repository, sha1); enum input_source src = istream_source(real, type, &oi); if (src < 0) -- 2.15.1.433.g936d1b9894.dirty