pack-bitmap-write: convert some helpers to use object_id

A few functions take raw hash pointers, but all of their callers actually have a "struct object_id". Let's retain that extra type as long as possible (which will let future patches extend that further, and so on). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jun 20, 2019 at 03:40 UTC 05805d7411a78b606c4bca2f0288fd842df6addd
1 file changed +9 -9
pack-bitmap-write.c
+9 -9
@@ -142,13 +142,13 @@ static inline void reset_all_seen(void)
142 seen_objects_nr = 0;
143 }
144
145 -static uint32_t find_object_pos(const unsigned char *hash)
145 +static uint32_t find_object_pos(const struct object_id *oid)
146 {
147 - struct object_entry *entry = packlist_find(writer.to_pack, hash, NULL);
147 + struct object_entry *entry = packlist_find(writer.to_pack, oid->hash, NULL);
148
149 if (!entry) {
150 die("Failed to write bitmap index. Packfile doesn't have full closure "
151 - "(object %s is missing)", hash_to_hex(hash));
151 + "(object %s is missing)", oid_to_hex(oid));
152 }
153
154 return oe_in_pack_pos(writer.to_pack, entry);
@@ -157,7 +157,7 @@ static uint32_t find_object_pos(const unsigned char *hash)
157 static void show_object(struct object *object, const char *name, void *data)
158 {
159 struct bitmap *base = data;
160 - bitmap_set(base, find_object_pos(object->oid.hash));
160 + bitmap_set(base, find_object_pos(&object->oid));
161 mark_as_seen(object);
162 }
163
@@ -170,7 +170,7 @@ static int
170 add_to_include_set(struct bitmap *base, struct commit *commit)
171 {
172 khiter_t hash_pos;
173 - uint32_t bitmap_pos = find_object_pos(commit->object.oid.hash);
173 + uint32_t bitmap_pos = find_object_pos(&commit->object.oid);
174
175 if (bitmap_get(base, bitmap_pos))
176 return 0;
@@ -375,14 +375,14 @@ void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack)
375 */
376 }
377
378 -static struct ewah_bitmap *find_reused_bitmap(const unsigned char *sha1)
378 +static struct ewah_bitmap *find_reused_bitmap(const struct object_id *oid)
379 {
380 khiter_t hash_pos;
381
382 if (!writer.reused)
383 return NULL;
384
385 - hash_pos = kh_get_sha1(writer.reused, sha1);
385 + hash_pos = kh_get_sha1(writer.reused, oid->hash);
386 if (hash_pos >= kh_end(writer.reused))
387 return NULL;
388
@@ -422,14 +422,14 @@ void bitmap_writer_select_commits(struct commit **indexed_commits,
422
423 if (next == 0) {
424 chosen = indexed_commits[i];
425 - reused_bitmap = find_reused_bitmap(chosen->object.oid.hash);
425 + reused_bitmap = find_reused_bitmap(&chosen->object.oid);
426 } else {
427 chosen = indexed_commits[i + next];
428
429 for (j = 0; j <= next; ++j) {
430 struct commit *cm = indexed_commits[i + j];
431
432 - reused_bitmap = find_reused_bitmap(cm->object.oid.hash);
432 + reused_bitmap = find_reused_bitmap(&cm->object.oid);
433 if (reused_bitmap || (cm->object.flags & NEEDS_BITMAP) != 0) {
434 chosen = cm;
435 break;