sha1_file: allow link_alt_odb_entries to handle arbitrary repositories
[gitweb.git] / packfile.c
index 8b27b69bff26cab34bf67ad3e7f8a2b7c5f0a4b4..d087eacc066761d8b583939eb0db993cc5f31dbc 100644 (file)
@@ -803,8 +803,6 @@ static void prepare_packed_git_one(char *objdir, int local)
        strbuf_release(&path);
 }
 
-static int approximate_object_count_valid;
-
 /*
  * 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
@@ -814,8 +812,8 @@ static int approximate_object_count_valid;
  */
 unsigned long approximate_object_count(void)
 {
-       static unsigned long count;
-       if (!approximate_object_count_valid) {
+       if (!the_repository->objects->approximate_object_count_valid) {
+               unsigned long count;
                struct packed_git *p;
 
                prepare_packed_git();
@@ -825,8 +823,9 @@ unsigned long approximate_object_count(void)
                                continue;
                        count += p->num_objects;
                }
+               the_repository->objects->approximate_object_count = count;
        }
-       return count;
+       return the_repository->objects->approximate_object_count;
 }
 
 static void *get_next_packed_git(const void *p)
@@ -884,26 +883,25 @@ static void prepare_packed_git_mru(void)
                list_add_tail(&p->mru, &the_repository->objects->packed_git_mru);
 }
 
-static int prepare_packed_git_run_once = 0;
 void prepare_packed_git(void)
 {
        struct alternate_object_database *alt;
 
-       if (prepare_packed_git_run_once)
+       if (the_repository->objects->packed_git_initialized)
                return;
        prepare_packed_git_one(get_object_directory(), 1);
-       prepare_alt_odb();
+       prepare_alt_odb(the_repository);
        for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next)
                prepare_packed_git_one(alt->path, 0);
        rearrange_packed_git();
        prepare_packed_git_mru();
-       prepare_packed_git_run_once = 1;
+       the_repository->objects->packed_git_initialized = 1;
 }
 
 void reprepare_packed_git(void)
 {
-       approximate_object_count_valid = 0;
-       prepare_packed_git_run_once = 0;
+       the_repository->objects->approximate_object_count_valid = 0;
+       the_repository->objects->packed_git_initialized = 0;
        prepare_packed_git();
 }