From: Jonathan Nieder <jrnieder@xxxxxxxxx> Add a repository argument to allow callers of find_pack_entry 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> --- packfile.c | 4 ++-- packfile.h | 3 ++- sha1_file.c | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packfile.c b/packfile.c index 61e84a789c..f641f6329a 100644 --- a/packfile.c +++ b/packfile.c @@ -1835,7 +1835,7 @@ static int fill_pack_entry(const unsigned char *sha1, * Iff a pack file contains the object named by sha1, return true and * store its location to e. */ -int find_pack_entry(const unsigned char *sha1, struct pack_entry *e) +int find_pack_entry_the_repository(const unsigned char *sha1, struct pack_entry *e) { struct mru_entry *p; @@ -1855,7 +1855,7 @@ int find_pack_entry(const unsigned char *sha1, struct pack_entry *e) int has_sha1_pack(const unsigned char *sha1) { struct pack_entry e; - return find_pack_entry(sha1, &e); + return find_pack_entry(the_repository, sha1, &e); } int has_pack_index(const unsigned char *sha1) diff --git a/packfile.h b/packfile.h index bb1d92b849..b42e5c2db1 100644 --- a/packfile.h +++ b/packfile.h @@ -141,7 +141,8 @@ extern int packed_object_info_the_repository(struct packed_git *pack, off_t offs extern void mark_bad_packed_object(struct packed_git *p, const unsigned char *sha1); extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1); -extern int find_pack_entry(const unsigned char *sha1, struct pack_entry *e); +#define find_pack_entry(r, s, e) find_pack_entry_##r(s, e) +extern int find_pack_entry_the_repository(const unsigned char *sha1, struct pack_entry *e); extern int has_sha1_pack(const unsigned char *sha1); diff --git a/sha1_file.c b/sha1_file.c index 299e8be72c..7e06ece5f3 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1272,7 +1272,7 @@ int sha1_object_info_extended_the_repository(const unsigned char *sha1, struct o } } - if (!find_pack_entry(real, &e)) { + if (!find_pack_entry(the_repository, real, &e)) { /* Most likely it's a loose object. */ if (!sha1_loose_object_info(the_repository, real, oi, flags)) return 0; @@ -1282,7 +1282,7 @@ int sha1_object_info_extended_the_repository(const unsigned char *sha1, struct o return -1; } else { reprepare_packed_git(the_repository); - if (!find_pack_entry(real, &e)) + if (!find_pack_entry(the_repository, real, &e)) return -1; } } @@ -1648,7 +1648,7 @@ static int freshen_loose_object(const unsigned char *sha1) static int freshen_packed_object(const unsigned char *sha1) { struct pack_entry e; - if (!find_pack_entry(sha1, &e)) + if (!find_pack_entry(the_repository, sha1, &e)) return 0; if (e.p->freshened) return 1; -- 2.15.1.433.g936d1b9894.dirty