aboutsummaryrefslogtreecommitdiff
path: root/oidset.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-11-19 08:50:54 +0100
committerJunio C Hamano <gitster@pobox.com>2025-11-25 12:15:59 -0800
commit5d795b34dcbf46039c3dda028bb8df8d75a5a9d0 (patch)
tree808c363b24b5949324ed160786195a61ee487dba /oidset.h
parentb67b2d9fb7ccfaa72446d76abc8c36849d2e0685 (diff)
downloadgit-5d795b34dcbf46039c3dda028bb8df8d75a5a9d0.tar.xz
oidset: introduce `oidset_equal()`
Introduce a new function that allows the caller to verify whether two oidsets contain the exact same object IDs. Note that this change requires us to change `oidset_iter_init()` to accept a `const struct oidset`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'oidset.h')
-rw-r--r--oidset.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/oidset.h b/oidset.h
index 0106b6f278..e0f1a6ff4f 100644
--- a/oidset.h
+++ b/oidset.h
@@ -39,6 +39,11 @@ void oidset_init(struct oidset *set, size_t initial_size);
int oidset_contains(const struct oidset *set, const struct object_id *oid);
/**
+ * Returns true iff `a` and `b` contain the exact same OIDs.
+ */
+bool oidset_equal(const struct oidset *a, const struct oidset *b);
+
+/**
* Insert the oid into the set; a copy is made, so "oid" does not need
* to persist after this function is called.
*
@@ -94,11 +99,11 @@ void oidset_parse_file_carefully(struct oidset *set, const char *path,
oidset_parse_tweak_fn fn, void *cbdata);
struct oidset_iter {
- kh_oid_set_t *set;
+ const kh_oid_set_t *set;
khiter_t iter;
};
-static inline void oidset_iter_init(struct oidset *set,
+static inline void oidset_iter_init(const struct oidset *set,
struct oidset_iter *iter)
{
iter->set = &set->set;