diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-11-19 08:50:54 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-11-25 12:15:59 -0800 |
| commit | 5d795b34dcbf46039c3dda028bb8df8d75a5a9d0 (patch) | |
| tree | 808c363b24b5949324ed160786195a61ee487dba /oidset.c | |
| parent | b67b2d9fb7ccfaa72446d76abc8c36849d2e0685 (diff) | |
| download | git-5d795b34dcbf46039c3dda028bb8df8d75a5a9d0.tar.gz | |
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.c')
| -rw-r--r-- | oidset.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -16,6 +16,22 @@ int oidset_contains(const struct oidset *set, const struct object_id *oid) return pos != kh_end(&set->set); } +bool oidset_equal(const struct oidset *a, const struct oidset *b) +{ + struct oidset_iter iter; + struct object_id *a_oid; + + if (oidset_size(a) != oidset_size(b)) + return false; + + oidset_iter_init(a, &iter); + while ((a_oid = oidset_iter_next(&iter))) + if (!oidset_contains(b, a_oid)) + return false; + + return true; +} + int oidset_insert(struct oidset *set, const struct object_id *oid) { int added; |
