struct ewah_bitmap *blobs;
struct ewah_bitmap *tags;
- /* Map from SHA1 -> `stored_bitmap` for all the bitmapped commits */
- khash_sha1 *bitmaps;
+ /* Map from object ID -> `stored_bitmap` for all the bitmapped commits */
+ kh_oid_map_t *bitmaps;
/* Number of bitmapped commits */
uint32_t entry_count;
struct object **objects;
uint32_t *hashes;
uint32_t count, alloc;
- khash_sha1_pos *positions;
+ kh_oid_pos_t *positions;
} ext_index;
/* Bitmap result of the last performed walk */
{
struct bitmap_disk_header *header = (void *)index->map;
- if (index->map_size < sizeof(*header) + 20)
+ if (index->map_size < sizeof(*header) + the_hash_algo->rawsz)
return error("Corrupted bitmap index (missing header data)");
if (memcmp(header->magic, BITMAP_IDX_SIGNATURE, sizeof(BITMAP_IDX_SIGNATURE)) != 0)
"(Git requires BITMAP_OPT_FULL_DAG)");
if (flags & BITMAP_OPT_HASH_CACHE) {
- unsigned char *end = index->map + index->map_size - 20;
+ unsigned char *end = index->map + index->map_size - the_hash_algo->rawsz;
index->hashes = ((uint32_t *)end) - index->pack->num_objects;
}
}
stored->flags = flags;
oidread(&stored->oid, hash);
- hash_pos = kh_put_sha1(index->bitmaps, stored->oid.hash, &ret);
+ hash_pos = kh_put_oid_map(index->bitmaps, stored->oid, &ret);
/* a 0 return code means the insertion succeeded with no changes,
* because the SHA1 already existed on the map. this is bad, there
{
assert(bitmap_git->map);
- bitmap_git->bitmaps = kh_init_sha1();
- bitmap_git->ext_index.positions = kh_init_sha1_pos();
- load_pack_revindex(bitmap_git->pack);
+ bitmap_git->bitmaps = kh_init_oid_map();
+ bitmap_git->ext_index.positions = kh_init_oid_pos();
+ if (load_pack_revindex(bitmap_git->pack))
+ goto failed;
if (!(bitmap_git->commits = read_bitmap_1(bitmap_git)) ||
!(bitmap_git->trees = read_bitmap_1(bitmap_git)) ||
};
static inline int bitmap_position_extended(struct bitmap_index *bitmap_git,
- const unsigned char *sha1)
+ const struct object_id *oid)
{
- khash_sha1_pos *positions = bitmap_git->ext_index.positions;
- khiter_t pos = kh_get_sha1_pos(positions, sha1);
+ khash_oid_pos *positions = bitmap_git->ext_index.positions;
+ khiter_t pos = kh_get_oid_pos(positions, *oid);
if (pos < kh_end(positions)) {
int bitmap_pos = kh_value(positions, pos);
}
static inline int bitmap_position_packfile(struct bitmap_index *bitmap_git,
- const unsigned char *sha1)
+ const struct object_id *oid)
{
- off_t offset = find_pack_entry_one(sha1, bitmap_git->pack);
+ off_t offset = find_pack_entry_one(oid->hash, bitmap_git->pack);
if (!offset)
return -1;
}
static int bitmap_position(struct bitmap_index *bitmap_git,
- const unsigned char *sha1)
+ const struct object_id *oid)
{
- int pos = bitmap_position_packfile(bitmap_git, sha1);
- return (pos >= 0) ? pos : bitmap_position_extended(bitmap_git, sha1);
+ int pos = bitmap_position_packfile(bitmap_git, oid);
+ return (pos >= 0) ? pos : bitmap_position_extended(bitmap_git, oid);
}
static int ext_index_add_object(struct bitmap_index *bitmap_git,
int hash_ret;
int bitmap_pos;
- hash_pos = kh_put_sha1_pos(eindex->positions, object->oid.hash, &hash_ret);
+ hash_pos = kh_put_oid_pos(eindex->positions, object->oid, &hash_ret);
if (hash_ret > 0) {
if (eindex->count >= eindex->alloc) {
eindex->alloc = (eindex->alloc + 16) * 3 / 2;
struct bitmap_show_data *data = data_;
int bitmap_pos;
- bitmap_pos = bitmap_position(data->bitmap_git, object->oid.hash);
+ bitmap_pos = bitmap_position(data->bitmap_git, &object->oid);
if (bitmap_pos < 0)
bitmap_pos = ext_index_add_object(data->bitmap_git, object,
static int add_to_include_set(struct bitmap_index *bitmap_git,
struct include_data *data,
- const unsigned char *sha1,
+ const struct object_id *oid,
int bitmap_pos)
{
khiter_t hash_pos;
if (bitmap_get(data->base, bitmap_pos))
return 0;
- hash_pos = kh_get_sha1(bitmap_git->bitmaps, sha1);
+ hash_pos = kh_get_oid_map(bitmap_git->bitmaps, *oid);
if (hash_pos < kh_end(bitmap_git->bitmaps)) {
struct stored_bitmap *st = kh_value(bitmap_git->bitmaps, hash_pos);
bitmap_or_ewah(data->base, lookup_stored_bitmap(st));
struct include_data *data = _data;
int bitmap_pos;
- bitmap_pos = bitmap_position(data->bitmap_git, commit->object.oid.hash);
+ bitmap_pos = bitmap_position(data->bitmap_git, &commit->object.oid);
if (bitmap_pos < 0)
bitmap_pos = ext_index_add_object(data->bitmap_git,
(struct object *)commit,
NULL);
- if (!add_to_include_set(data->bitmap_git, data, commit->object.oid.hash,
+ if (!add_to_include_set(data->bitmap_git, data, &commit->object.oid,
bitmap_pos)) {
struct commit_list *parent = commit->parents;
roots = roots->next;
if (object->type == OBJ_COMMIT) {
- khiter_t pos = kh_get_sha1(bitmap_git->bitmaps, object->oid.hash);
+ khiter_t pos = kh_get_oid_map(bitmap_git->bitmaps, object->oid);
if (pos < kh_end(bitmap_git->bitmaps)) {
struct stored_bitmap *st = kh_value(bitmap_git->bitmaps, pos);
int pos;
roots = roots->next;
- pos = bitmap_position(bitmap_git, object->oid.hash);
+ pos = bitmap_position(bitmap_git, &object->oid);
if (pos < 0 || base == NULL || !bitmap_get(base, pos)) {
object->flags &= ~UNINTERESTING;
struct bitmap_test_data *tdata = data;
int bitmap_pos;
- bitmap_pos = bitmap_position(tdata->bitmap_git, object->oid.hash);
+ bitmap_pos = bitmap_position(tdata->bitmap_git, &object->oid);
if (bitmap_pos < 0)
die("Object not in bitmap: %s\n", oid_to_hex(&object->oid));
int bitmap_pos;
bitmap_pos = bitmap_position(tdata->bitmap_git,
- commit->object.oid.hash);
+ &commit->object.oid);
if (bitmap_pos < 0)
die("Object not in bitmap: %s\n", oid_to_hex(&commit->object.oid));
bitmap_git->version, bitmap_git->entry_count);
root = revs->pending.objects[0].item;
- pos = kh_get_sha1(bitmap_git->bitmaps, root->oid.hash);
+ pos = kh_get_oid_map(bitmap_git->bitmaps, root->oid);
if (pos < kh_end(bitmap_git->bitmaps)) {
struct stored_bitmap *st = kh_value(bitmap_git->bitmaps, pos);
ewah_pool_free(b->trees);
ewah_pool_free(b->blobs);
ewah_pool_free(b->tags);
- kh_destroy_sha1(b->bitmaps);
+ kh_destroy_oid_map(b->bitmaps);
free(b->ext_index.objects);
free(b->ext_index.hashes);
bitmap_free(b->result);
free(b);
}
-int bitmap_has_sha1_in_uninteresting(struct bitmap_index *bitmap_git,
- const unsigned char *sha1)
+int bitmap_has_oid_in_uninteresting(struct bitmap_index *bitmap_git,
+ const struct object_id *oid)
{
int pos;
if (!bitmap_git->haves)
return 0; /* walk had no "haves" */
- pos = bitmap_position_packfile(bitmap_git, sha1);
+ pos = bitmap_position_packfile(bitmap_git, oid);
if (pos < 0)
return 0;