commit-reach: move walk methods from commit.c
[gitweb.git] / pack-bitmap.c
index 42e3d5f4f26ee0f31d13c2a3d15bc31da5f7c1d4..18f8b22aeb422bb81999e1e564006daf8b64f637 100644 (file)
@@ -10,6 +10,8 @@
 #include "pack-revindex.h"
 #include "pack-objects.h"
 #include "packfile.h"
+#include "repository.h"
+#include "object-store.h"
 
 /*
  * An entry on the bitmap index, representing the bitmap for a given
@@ -118,7 +120,7 @@ static struct ewah_bitmap *read_bitmap_1(struct bitmap_index *index)
 {
        struct ewah_bitmap *b = ewah_pool_new();
 
-       int bitmap_size = ewah_read_mmap(b,
+       ssize_t bitmap_size = ewah_read_mmap(b,
                index->map + index->map_pos,
                index->map_size - index->map_pos);
 
@@ -253,7 +255,7 @@ static char *pack_bitmap_filename(struct packed_git *p)
        size_t len;
 
        if (!strip_suffix(p->pack_name, ".pack", &len))
-               die("BUG: pack_name does not end in .pack");
+               BUG("pack_name does not end in .pack");
        return xstrfmt("%.*s.bitmap", (int)len, p->pack_name);
 }
 
@@ -334,8 +336,7 @@ static int open_pack_bitmap(void)
 
        assert(!bitmap_git.map && !bitmap_git.loaded);
 
-       prepare_packed_git();
-       for (p = packed_git; p; p = p->next) {
+       for (p = get_packed_git(the_repository); p; p = p->next) {
                if (open_pack_bitmap_1(p) == 0)
                        ret = 0;
        }
@@ -587,7 +588,7 @@ static void show_extended_objects(struct bitmap *objects,
                        continue;
 
                obj = eindex->objects[i];
-               show_reach(obj->oid.hash, obj->type, 0, eindex->hashes[i], NULL, 0);
+               show_reach(&obj->oid, obj->type, 0, eindex->hashes[i], NULL, 0);
        }
 }
 
@@ -612,7 +613,7 @@ static void show_objects_for_type(
                eword_t word = objects->words[i] & filter;
 
                for (offset = 0; offset < BITS_IN_EWORD; ++offset) {
-                       const unsigned char *sha1;
+                       struct object_id oid;
                        struct revindex_entry *entry;
                        uint32_t hash = 0;
 
@@ -625,12 +626,12 @@ static void show_objects_for_type(
                                continue;
 
                        entry = &bitmap_git.pack->revindex[pos + offset];
-                       sha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);
+                       nth_packed_object_oid(&oid, bitmap_git.pack, entry->nr);
 
                        if (bitmap_git.hashes)
                                hash = get_be32(bitmap_git.hashes + entry->nr);
 
-                       show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset);
+                       show_reach(&oid, object_type, 0, hash, bitmap_git.pack, entry->offset);
                }
 
                pos += BITS_IN_EWORD;
@@ -722,13 +723,13 @@ int prepare_bitmap_walk(struct rev_info *revs)
                revs->ignore_missing_links = 0;
 
                if (haves_bitmap == NULL)
-                       die("BUG: failed to perform bitmap walk");
+                       BUG("failed to perform bitmap walk");
        }
 
        wants_bitmap = find_objects(revs, wants, haves_bitmap);
 
        if (!wants_bitmap)
-               die("BUG: failed to perform bitmap walk");
+               BUG("failed to perform bitmap walk");
 
        if (haves_bitmap)
                bitmap_and_not(wants_bitmap, haves_bitmap);
@@ -1032,7 +1033,7 @@ int rebuild_existing_bitmaps(struct packing_data *mapping,
                oe = packlist_find(mapping, sha1, NULL);
 
                if (oe)
-                       reposition[i] = oe->in_pack_pos + 1;
+                       reposition[i] = oe_in_pack_pos(mapping, oe) + 1;
        }
 
        rebuild = bitmap_new();