test-lib: introduce test_commit_bulk
[gitweb.git] / packfile.c
index cdf6b6ec3443cfe3fcabb55a4475a9fc64c8543b..d786ec731202e5d623a7558bec2168194db11514 100644 (file)
@@ -640,7 +640,7 @@ unsigned char *use_pack(struct packed_git *p,
                        while (packed_git_limit < pack_mapped
                                && unuse_one_window(p))
                                ; /* nothing */
-                       win->base = xmmap(NULL, win->len,
+                       win->base = xmmap_gently(NULL, win->len,
                                PROT_READ, MAP_PRIVATE,
                                p->pack_fd, win->offset);
                        if (win->base == MAP_FAILED)
@@ -903,25 +903,25 @@ static void prepare_packed_git(struct repository *r);
  * all unreachable objects about to be pruned, in which case they're not really
  * interesting as a measure of repo size in the first place.
  */
-unsigned long approximate_object_count(void)
+unsigned long repo_approximate_object_count(struct repository *r)
 {
-       if (!the_repository->objects->approximate_object_count_valid) {
+       if (!r->objects->approximate_object_count_valid) {
                unsigned long count;
                struct multi_pack_index *m;
                struct packed_git *p;
 
-               prepare_packed_git(the_repository);
+               prepare_packed_git(r);
                count = 0;
-               for (m = get_multi_pack_index(the_repository); m; m = m->next)
+               for (m = get_multi_pack_index(r); m; m = m->next)
                        count += m->num_objects;
-               for (p = the_repository->objects->packed_git; p; p = p->next) {
+               for (p = r->objects->packed_git; p; p = p->next) {
                        if (open_pack_index(p))
                                continue;
                        count += p->num_objects;
                }
-               the_repository->objects->approximate_object_count = count;
+               r->objects->approximate_object_count = count;
        }
-       return the_repository->objects->approximate_object_count;
+       return r->objects->approximate_object_count;
 }
 
 static void *get_next_packed_git(const void *p)
@@ -994,8 +994,6 @@ static void prepare_packed_git(struct repository *r)
        }
        rearrange_packed_git(r);
 
-       r->objects->all_packs = NULL;
-
        prepare_packed_git_mru(r);
        r->objects->packed_git_initialized = 1;
 }
@@ -1026,26 +1024,16 @@ struct multi_pack_index *get_multi_pack_index(struct repository *r)
 
 struct packed_git *get_all_packs(struct repository *r)
 {
-       prepare_packed_git(r);
-
-       if (!r->objects->all_packs) {
-               struct packed_git *p = r->objects->packed_git;
-               struct multi_pack_index *m;
-
-               for (m = r->objects->multi_pack_index; m; m = m->next) {
-                       uint32_t i;
-                       for (i = 0; i < m->num_packs; i++) {
-                               if (!prepare_midx_pack(m, i)) {
-                                       m->packs[i]->next = p;
-                                       p = m->packs[i];
-                               }
-                       }
-               }
+       struct multi_pack_index *m;
 
-               r->objects->all_packs = p;
+       prepare_packed_git(r);
+       for (m = r->objects->multi_pack_index; m; m = m->next) {
+               uint32_t i;
+               for (i = 0; i < m->num_packs; i++)
+                       prepare_midx_pack(r, m, i);
        }
 
-       return r->objects->all_packs;
+       return r->objects->packed_git;
 }
 
 struct list_head *get_packed_git_mru(struct repository *r)
@@ -1998,13 +1986,13 @@ int find_pack_entry(struct repository *r, const struct object_id *oid, struct pa
                return 0;
 
        for (m = r->objects->multi_pack_index; m; m = m->next) {
-               if (fill_midx_entry(oid, e, m))
+               if (fill_midx_entry(r, oid, e, m))
                        return 1;
        }
 
        list_for_each(pos, &r->objects->packed_git_mru) {
                struct packed_git *p = list_entry(pos, struct packed_git, mru);
-               if (fill_pack_entry(oid, e, p)) {
+               if (!p->multi_pack_index && fill_pack_entry(oid, e, p)) {
                        list_move(&p->mru, &r->objects->packed_git_mru);
                        return 1;
                }