pack-bitmap: allow passing payloads to `show_reachable_fn()`

The `show_reachable_fn` callback is used by a couple of functions to present reachable objects to the caller. The function does not provide a way for the caller to pass a payload though, which is functionality that we'll require in a subsequent commit. Change the callback type to accept a payload and adapt all callsites accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Apr 2, 2025 at 13:13 UTC 3d45483846368796d12f62d7d15daaa59d9d8a5c
5 files changed +16 -11
builtin/pack-objects.c
+2 -1
@@ -1736,7 +1736,8 @@ static int add_object_entry(const struct object_id *oid, enum object_type type,
1736 static int add_object_entry_from_bitmap(const struct object_id *oid,
1737 enum object_type type,
1738 int flags UNUSED, uint32_t name_hash,
1739 - struct packed_git *pack, off_t offset)
1739 + struct packed_git *pack, off_t offset,
1740 + void *payload UNUSED)
1741 {
1742 display_progress(progress_state, ++nr_seen);
1743
builtin/rev-list.c
+2 -1
@@ -429,7 +429,8 @@ static int show_object_fast(
429 int exclude UNUSED,
430 uint32_t name_hash UNUSED,
431 struct packed_git *found_pack UNUSED,
432 - off_t found_offset UNUSED)
432 + off_t found_offset UNUSED,
433 + void *payload UNUSED)
434 {
435 fprintf(stdout, "%s\n", oid_to_hex(oid));
436 return 1;
pack-bitmap.c
+8 -7
@@ -1625,7 +1625,7 @@ static void show_extended_objects(struct bitmap_index *bitmap_git,
1625 (obj->type == OBJ_TAG && !revs->tag_objects))
1626 continue;
1627
1628 - show_reach(&obj->oid, obj->type, 0, eindex->hashes[i], NULL, 0);
1628 + show_reach(&obj->oid, obj->type, 0, eindex->hashes[i], NULL, 0, NULL);
1629 }
1630 }
1631
@@ -1663,7 +1663,8 @@ static void init_type_iterator(struct ewah_or_iterator *it,
1663 static void show_objects_for_type(
1664 struct bitmap_index *bitmap_git,
1665 enum object_type object_type,
1666 - show_reachable_fn show_reach)
1666 + show_reachable_fn show_reach,
1667 + void *payload)
1668 {
1669 size_t i = 0;
1670 uint32_t offset;
@@ -1715,7 +1716,7 @@ static void show_objects_for_type(
1716 if (bitmap_git->hashes)
1717 hash = get_be32(bitmap_git->hashes + index_pos);
1718
1718 - show_reach(&oid, object_type, 0, hash, pack, ofs);
1719 + show_reach(&oid, object_type, 0, hash, pack, ofs, payload);
1720 }
1721 }
1722
@@ -2518,13 +2519,13 @@ void traverse_bitmap_commit_list(struct bitmap_index *bitmap_git,
2519 {
2520 assert(bitmap_git->result);
2521
2521 - show_objects_for_type(bitmap_git, OBJ_COMMIT, show_reachable);
2522 + show_objects_for_type(bitmap_git, OBJ_COMMIT, show_reachable, NULL);
2523 if (revs->tree_objects)
2523 - show_objects_for_type(bitmap_git, OBJ_TREE, show_reachable);
2524 + show_objects_for_type(bitmap_git, OBJ_TREE, show_reachable, NULL);
2525 if (revs->blob_objects)
2525 - show_objects_for_type(bitmap_git, OBJ_BLOB, show_reachable);
2526 + show_objects_for_type(bitmap_git, OBJ_BLOB, show_reachable, NULL);
2527 if (revs->tag_objects)
2527 - show_objects_for_type(bitmap_git, OBJ_TAG, show_reachable);
2528 + show_objects_for_type(bitmap_git, OBJ_TAG, show_reachable, NULL);
2529
2530 show_extended_objects(bitmap_git, revs, show_reachable);
2531 }
pack-bitmap.h
+2 -1
@@ -50,7 +50,8 @@ typedef int (*show_reachable_fn)(
50 int flags,
51 uint32_t hash,
52 struct packed_git *found_pack,
53 - off_t found_offset);
53 + off_t found_offset,
54 + void *payload);
55
56 struct bitmap_index;
57
reachable.c
+2 -1
@@ -341,7 +341,8 @@ static int mark_object_seen(const struct object_id *oid,
341 int exclude UNUSED,
342 uint32_t name_hash UNUSED,
343 struct packed_git *found_pack UNUSED,
344 - off_t found_offset UNUSED)
344 + off_t found_offset UNUSED,
345 + void *payload UNUSED)
346 {
347 struct object *obj = lookup_object_by_type(the_repository, oid, type);
348 if (!obj)