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 <jrnie...@gmail.com>
Signed-off-by: Stefan Beller <sbel...@google.com>
---
 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 5e40e2152f..3dd937d4ef 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -25,7 +25,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 9f381c44eb..432a1b2b2a 100644
--- a/object.c
+++ b/object.c
@@ -247,7 +247,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 dbb128f4c3..6a2d37d717 100644
--- a/replace-object.h
+++ b/replace-object.h
@@ -23,7 +23,8 @@ extern const unsigned char 
*do_lookup_replace_object_the_repository(const unsign
  * 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 68f1735476..0dad6c211e 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1236,7 +1236,7 @@ int sha1_object_info_extended(const unsigned char *sha1, 
struct object_info *oi,
        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;
        int already_retried = 0;
 
@@ -1374,8 +1374,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 29632065d0..b36b3cc6b8 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.17.0.484.g0c8726318c-goog

Reply via email to