sha1_file: allow link_alt_odb_entries to handle arbitrary repositories
[gitweb.git] / packfile.c
index 98162a051332f102762a49ad08c638e8a870ed7e..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)
@@ -891,7 +890,7 @@ void prepare_packed_git(void)
        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();
@@ -901,7 +900,7 @@ void prepare_packed_git(void)
 
 void reprepare_packed_git(void)
 {
-       approximate_object_count_valid = 0;
+       the_repository->objects->approximate_object_count_valid = 0;
        the_repository->objects->packed_git_initialized = 0;
        prepare_packed_git();
 }