]> git.ipfire.org Git - thirdparty/git.git/blobdiff - packfile.c
packfile: keep prepare_packed_git() private
[thirdparty/git.git] / packfile.c
index fd6aa54b4bd90c5a24cc1f20d0e79ce0a709baac..0906b8f74184ebb83e20124c0946ecfd124653ee 100644 (file)
@@ -803,6 +803,7 @@ static void prepare_packed_git_one(struct repository *r, char *objdir, int local
        strbuf_release(&path);
 }
 
+static void prepare_packed_git(struct repository *r);
 /*
  * Give a fast, rough count of the number of objects in the repository. This
  * ignores loose objects completely. If you have a lot of them, then either
@@ -883,35 +884,37 @@ static void prepare_packed_git_mru(struct repository *r)
                list_add_tail(&p->mru, &r->objects->packed_git_mru);
 }
 
-void prepare_packed_git_the_repository(void)
+static void prepare_packed_git(struct repository *r)
 {
        struct alternate_object_database *alt;
 
-       if (the_repository->objects->packed_git_initialized)
+       if (r->objects->packed_git_initialized)
                return;
-       prepare_packed_git_one(the_repository, get_object_directory(), 1);
-       prepare_alt_odb(the_repository);
-       for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next)
-               prepare_packed_git_one(the_repository, alt->path, 0);
-       rearrange_packed_git(the_repository);
-       prepare_packed_git_mru(the_repository);
-       the_repository->objects->packed_git_initialized = 1;
+       prepare_packed_git_one(r, r->objects->objectdir, 1);
+       prepare_alt_odb(r);
+       for (alt = r->objects->alt_odb_list; alt; alt = alt->next)
+               prepare_packed_git_one(r, alt->path, 0);
+       rearrange_packed_git(r);
+       prepare_packed_git_mru(r);
+       r->objects->packed_git_initialized = 1;
 }
 
-void reprepare_packed_git_the_repository(void)
+void reprepare_packed_git(struct repository *r)
 {
-       the_repository->objects->approximate_object_count_valid = 0;
-       the_repository->objects->packed_git_initialized = 0;
-       prepare_packed_git(the_repository);
+       r->objects->approximate_object_count_valid = 0;
+       r->objects->packed_git_initialized = 0;
+       prepare_packed_git(r);
 }
 
 struct packed_git *get_packed_git(struct repository *r)
 {
+       prepare_packed_git(r);
        return r->objects->packed_git;
 }
 
 struct list_head *get_packed_git_mru(struct repository *r)
 {
+       prepare_packed_git(r);
        return &r->objects->packed_git_mru;
 }
 
@@ -1845,23 +1848,18 @@ static int fill_pack_entry(const unsigned char *sha1,
        return 1;
 }
 
-/*
- * 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(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;
                }
        }
@@ -1871,7 +1869,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)