Add a repository argument to allow the callers of has_packed_and_bad
to be more specific about which repository to act on. 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.

Add the cocci patch that converted the callers.

Signed-off-by: Jonathan Nieder <[email protected]>
Signed-off-by: Stefan Beller <[email protected]>
---
 packfile.c  | 2 +-
 packfile.h  | 4 +++-
 sha1_file.c | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/packfile.c b/packfile.c
index f7e8a81ded..28453739b2 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1004,7 +1004,7 @@ void mark_bad_packed_object(struct packed_git *p, const 
unsigned char *sha1)
        p->num_bad_objects++;
 }
 
-const struct packed_git *has_packed_and_bad(const unsigned char *sha1)
+const struct packed_git *has_packed_and_bad_the_repository(const unsigned char 
*sha1)
 {
        struct packed_git *p;
        unsigned i;
diff --git a/packfile.h b/packfile.h
index f8d2825cce..b5122d455e 100644
--- a/packfile.h
+++ b/packfile.h
@@ -140,7 +140,9 @@ extern int packed_object_info(struct repository *r,
                              off_t offset, struct object_info *);
 
 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);
+
+#define has_packed_and_bad(r, s) has_packed_and_bad_##r(s)
+extern const struct packed_git *has_packed_and_bad_the_repository(const 
unsigned char *sha1);
 
 extern int find_pack_entry(struct repository *r,
                           const unsigned char *sha1,
diff --git a/sha1_file.c b/sha1_file.c
index ca567b64d6..e1427c0982 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1386,7 +1386,7 @@ void *read_sha1_file_extended_the_repository(const 
unsigned char *sha1,
                die("loose object %s (stored in %s) is corrupt",
                    sha1_to_hex(repl), path);
 
-       if ((p = has_packed_and_bad(repl)) != NULL)
+       if ((p = has_packed_and_bad(the_repository, repl)) != NULL)
                die("packed object %s (stored in %s) is corrupt",
                    sha1_to_hex(repl), p->pack_name);
 
-- 
2.15.1.433.g936d1b9894.dirty

Reply via email to