t5510-fetch: fix negated 'test_i18ngrep' invocation
[gitweb.git] / pack-bitmap-write.c
index 802ed62677dc995cc08d747a7c85dc1f17109503..fa78a460c9aa5dd3b0c89960a23b7a410fca83d9 100644 (file)
@@ -28,8 +28,8 @@ struct bitmap_writer {
        struct ewah_bitmap *blobs;
        struct ewah_bitmap *tags;
 
-       khash_sha1 *bitmaps;
-       khash_sha1 *reused;
+       kh_oid_map_t *bitmaps;
+       kh_oid_map_t *reused;
        struct packing_data *to_pack;
 
        struct bitmapped_commit *selected;
@@ -142,13 +142,13 @@ static inline void reset_all_seen(void)
        seen_objects_nr = 0;
 }
 
-static uint32_t find_object_pos(const unsigned char *hash)
+static uint32_t find_object_pos(const struct object_id *oid)
 {
-       struct object_entry *entry = packlist_find(writer.to_pack, hash, NULL);
+       struct object_entry *entry = packlist_find(writer.to_pack, oid, NULL);
 
        if (!entry) {
                die("Failed to write bitmap index. Packfile doesn't have full closure "
-                       "(object %s is missing)", hash_to_hex(hash));
+                       "(object %s is missing)", oid_to_hex(oid));
        }
 
        return oe_in_pack_pos(writer.to_pack, entry);
@@ -157,7 +157,7 @@ static uint32_t find_object_pos(const unsigned char *hash)
 static void show_object(struct object *object, const char *name, void *data)
 {
        struct bitmap *base = data;
-       bitmap_set(base, find_object_pos(object->oid.hash));
+       bitmap_set(base, find_object_pos(&object->oid));
        mark_as_seen(object);
 }
 
@@ -170,12 +170,12 @@ static int
 add_to_include_set(struct bitmap *base, struct commit *commit)
 {
        khiter_t hash_pos;
-       uint32_t bitmap_pos = find_object_pos(commit->object.oid.hash);
+       uint32_t bitmap_pos = find_object_pos(&commit->object.oid);
 
        if (bitmap_get(base, bitmap_pos))
                return 0;
 
-       hash_pos = kh_get_sha1(writer.bitmaps, commit->object.oid.hash);
+       hash_pos = kh_get_oid_map(writer.bitmaps, commit->object.oid);
        if (hash_pos < kh_end(writer.bitmaps)) {
                struct bitmapped_commit *bc = kh_value(writer.bitmaps, hash_pos);
                bitmap_or_ewah(base, bc->bitmap);
@@ -256,7 +256,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
        struct bitmap *base = bitmap_new();
        struct rev_info revs;
 
-       writer.bitmaps = kh_init_sha1();
+       writer.bitmaps = kh_init_oid_map();
        writer.to_pack = to_pack;
 
        if (writer.show_progress)
@@ -311,7 +311,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
                if (i >= reuse_after)
                        stored->flags |= BITMAP_FLAG_REUSE;
 
-               hash_pos = kh_put_sha1(writer.bitmaps, object->oid.hash, &hash_ret);
+               hash_pos = kh_put_oid_map(writer.bitmaps, object->oid, &hash_ret);
                if (hash_ret == 0)
                        die("Duplicate entry when writing index: %s",
                            oid_to_hex(&object->oid));
@@ -366,7 +366,7 @@ void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack)
        if (!(bitmap_git = prepare_bitmap_git(to_pack->repo)))
                return;
 
-       writer.reused = kh_init_sha1();
+       writer.reused = kh_init_oid_map();
        rebuild_existing_bitmaps(bitmap_git, to_pack, writer.reused,
                                 writer.show_progress);
        /*
@@ -375,14 +375,14 @@ void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack)
         */
 }
 
-static struct ewah_bitmap *find_reused_bitmap(const unsigned char *sha1)
+static struct ewah_bitmap *find_reused_bitmap(const struct object_id *oid)
 {
        khiter_t hash_pos;
 
        if (!writer.reused)
                return NULL;
 
-       hash_pos = kh_get_sha1(writer.reused, sha1);
+       hash_pos = kh_get_oid_map(writer.reused, *oid);
        if (hash_pos >= kh_end(writer.reused))
                return NULL;
 
@@ -422,14 +422,14 @@ void bitmap_writer_select_commits(struct commit **indexed_commits,
 
                if (next == 0) {
                        chosen = indexed_commits[i];
-                       reused_bitmap = find_reused_bitmap(chosen->object.oid.hash);
+                       reused_bitmap = find_reused_bitmap(&chosen->object.oid);
                } else {
                        chosen = indexed_commits[i + next];
 
                        for (j = 0; j <= next; ++j) {
                                struct commit *cm = indexed_commits[i + j];
 
-                               reused_bitmap = find_reused_bitmap(cm->object.oid.hash);
+                               reused_bitmap = find_reused_bitmap(&cm->object.oid);
                                if (reused_bitmap || (cm->object.flags & NEEDS_BITMAP) != 0) {
                                        chosen = cm;
                                        break;