diff mbox series

[v3,14/30] pack-bitmap: implement `bitmap_writer_has_bitmapped_object_id()`

Message ID 99d2b6872baf5702aca74429c7c31b6fab5b1ec0.1716318089.git.me@ttaylorr.com (mailing list archive)
State Superseded
Headers show
Series pack-bitmap: pseudo-merge reachability bitmaps | expand

Commit Message

Taylor Blau May 21, 2024, 7:02 p.m. UTC
Prepare to implement pseudo-merge bitmap selection by implementing a
necessary new function, `bitmap_writer_has_bitmapped_object_id()`.

This function returns whether or not the bitmap_writer selected the
given object ID for bitmapping. This will allow the pseudo-merge
machinery to reject candidates for pseudo-merges if they have already
been selected as an ordinary bitmap tip.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 pack-bitmap-write.c | 6 ++++++
 pack-bitmap.h       | 2 ++
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 60eb1e71c98..299aa8af6f5 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -130,6 +130,12 @@  void bitmap_writer_build_type_index(struct bitmap_writer *writer,
 	}
 }
 
+int bitmap_writer_has_bitmapped_object_id(struct bitmap_writer *writer,
+					  const struct object_id *oid)
+{
+	return kh_get_oid_map(writer->bitmaps, *oid) != kh_end(writer->bitmaps);
+}
+
 /**
  * Compute the actual bitmaps
  */
diff --git a/pack-bitmap.h b/pack-bitmap.h
index 6937a0f090f..e175f28e0de 100644
--- a/pack-bitmap.h
+++ b/pack-bitmap.h
@@ -125,6 +125,8 @@  void bitmap_writer_build_type_index(struct bitmap_writer *writer,
 				    struct packing_data *to_pack,
 				    struct pack_idx_entry **index,
 				    uint32_t index_nr);
+int bitmap_writer_has_bitmapped_object_id(struct bitmap_writer *writer,
+					  const struct object_id *oid);
 uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git,
 				struct packing_data *mapping);
 int rebuild_bitmap(const uint32_t *reposition,