packfile: allow find_pack_entry to handle arbitrary repositories
authorStefan Beller <sbeller@google.com>
Fri, 23 Mar 2018 17:45:26 +0000 (18:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Mar 2018 17:07:43 +0000 (10:07 -0700)
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
packfile.c
packfile.h
index 9df123f0f19f2528477b2390187b9b3305fdca30..5d4c8d6e57eb1c8e39de5cc5af6fe4ff76d33994 100644 (file)
@@ -1845,19 +1845,18 @@ static int fill_pack_entry(const unsigned char *sha1,
        return 1;
 }
 
-int find_pack_entry_the_repository(const unsigned char *sha1, struct pack_entry *e)
+int find_pack_entry(struct repository *r, const unsigned char *sha1, struct pack_entry *e)
 {
        struct list_head *pos;
 
-       prepare_packed_git(the_repository);
-       if (!the_repository->objects->packed_git)
+       prepare_packed_git(r);
+       if (!r->objects->packed_git)
                return 0;
 
-       list_for_each(pos, &the_repository->objects->packed_git_mru) {
+       list_for_each(pos, &r->objects->packed_git_mru) {
                struct packed_git *p = list_entry(pos, struct packed_git, mru);
                if (fill_pack_entry(sha1, e, p)) {
-                       list_move(&p->mru,
-                                 &the_repository->objects->packed_git_mru);
+                       list_move(&p->mru, &r->objects->packed_git_mru);
                        return 1;
                }
        }
index e68f790ea7c224b480d8c9775d7850e287706d2b..fe1a6380e688bc8c28fa256c2ce87a1e8a76d402 100644 (file)
@@ -127,8 +127,7 @@ extern const struct packed_git *has_packed_and_bad(const unsigned char *sha1);
  * Iff a pack file in the given repository contains the object named by sha1,
  * return true and store its location to 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 find_pack_entry(struct repository *r, const unsigned char *sha1, struct pack_entry *e);
 
 extern int has_sha1_pack(const unsigned char *sha1);