Add a repository argument to allow callers of get_cached_commit_buffer 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: Stefan Beller <sbel...@google.com>
---
 builtin/rev-list.c | 2 +-
 commit.c           | 4 ++--
 commit.h           | 3 ++-
 log-tree.c         | 2 +-
 object.c           | 2 +-
 pretty.c           | 2 +-
 6 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 3c2ae454ea..e28e7426a5 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -133,7 +133,7 @@ static void show_commit(struct commit *commit, void *data)
        else
                putchar('\n');
 
-       if (revs->verbose_header && get_cached_commit_buffer(commit, NULL)) {
+       if (revs->verbose_header && get_cached_commit_buffer(the_repository, 
commit, NULL)) {
                struct strbuf buf = STRBUF_INIT;
                struct pretty_print_context ctx = {0};
                ctx.abbrev = revs->abbrev;
diff --git a/commit.c b/commit.c
index 5de78c73fd..1863900824 100644
--- a/commit.c
+++ b/commit.c
@@ -257,7 +257,7 @@ void set_commit_buffer_the_repository(struct commit 
*commit, void *buffer, unsig
        v->size = size;
 }
 
-const void *get_cached_commit_buffer(const struct commit *commit, unsigned 
long *sizep)
+const void *get_cached_commit_buffer_the_repository(const struct commit 
*commit, unsigned long *sizep)
 {
        struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);
        if (!v) {
@@ -272,7 +272,7 @@ const void *get_cached_commit_buffer(const struct commit 
*commit, unsigned long
 
 const void *get_commit_buffer(const struct commit *commit, unsigned long 
*sizep)
 {
-       const void *ret = get_cached_commit_buffer(commit, sizep);
+       const void *ret = get_cached_commit_buffer(the_repository, commit, 
sizep);
        if (!ret) {
                enum object_type type;
                unsigned long size;
diff --git a/commit.h b/commit.h
index d3ec52d1c1..bcecb23722 100644
--- a/commit.h
+++ b/commit.h
@@ -86,7 +86,8 @@ void set_commit_buffer_the_repository(struct commit *, void 
*buffer, unsigned lo
  * Get any cached object buffer associated with the commit. Returns NULL
  * if none. The resulting memory should not be freed.
  */
-const void *get_cached_commit_buffer(const struct commit *, unsigned long 
*size);
+#define get_cached_commit_buffer(r, c, s) get_cached_commit_buffer_##r(c, s)
+const void *get_cached_commit_buffer_the_repository(const struct commit *, 
unsigned long *size);
 
 /*
  * Get the commit's object contents, either from cache or by reading the object
diff --git a/log-tree.c b/log-tree.c
index 9fb333605b..c6d2883190 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -661,7 +661,7 @@ void show_log(struct rev_info *opt)
                show_mergetag(opt, commit);
        }
 
-       if (!get_cached_commit_buffer(commit, NULL))
+       if (!get_cached_commit_buffer(the_repository, commit, NULL))
                return;
 
        if (opt->show_notes) {
diff --git a/object.c b/object.c
index 7d848b5b7a..c2268990dd 100644
--- a/object.c
+++ b/object.c
@@ -214,7 +214,7 @@ struct object *parse_object_buffer_the_repository(const 
struct object_id *oid, e
                if (commit) {
                        if (parse_commit_buffer(the_repository, commit, buffer, 
size))
                                return NULL;
-                       if (!get_cached_commit_buffer(commit, NULL)) {
+                       if (!get_cached_commit_buffer(the_repository, commit, 
NULL)) {
                                set_commit_buffer(the_repository, commit, 
buffer, size);
                                *eaten_p = 1;
                        }
diff --git a/pretty.c b/pretty.c
index 478af1a860..f82d30cd97 100644
--- a/pretty.c
+++ b/pretty.c
@@ -630,7 +630,7 @@ const char *logmsg_reencode(const struct commit *commit,
                 * the cached copy from get_commit_buffer, we need to duplicate 
it
                 * to avoid munging the cached copy.
                 */
-               if (msg == get_cached_commit_buffer(commit, NULL))
+               if (msg == get_cached_commit_buffer(the_repository, commit, 
NULL))
                        out = xstrdup(msg);
                else
                        out = (char *)msg;
-- 
2.15.1.433.g936d1b9894.dirty

Reply via email to