diff options
author | Christian Couder <christian.couder@gmail.com> | 2024-02-14 15:25:11 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-14 18:39:14 +0100 |
commit | eaf07b7d15e067305d33150eb98bf0351f9f4cbd (patch) | |
tree | eb4ec48ac99f448027dbb95733a785140deb231e /oidset.c | |
parent | revision: clarify a 'return NULL' in get_reference() (diff) | |
download | git-eaf07b7d15e067305d33150eb98bf0351f9f4cbd.tar.xz git-eaf07b7d15e067305d33150eb98bf0351f9f4cbd.zip |
oidset: refactor oidset_insert_from_set()
In a following commit, we will need to add all the oids from a set into
another set. In "list-objects-filter.c", there is already a static
function called add_all() to do that.
Let's rename this function oidset_insert_from_set() and move it into
oidset.{c,h} to make it generally available.
While at it, let's remove a useless `!= NULL`.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'oidset.c')
-rw-r--r-- | oidset.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -23,6 +23,16 @@ int oidset_insert(struct oidset *set, const struct object_id *oid) return !added; } +void oidset_insert_from_set(struct oidset *dest, struct oidset *src) +{ + struct oidset_iter iter; + struct object_id *src_oid; + + oidset_iter_init(src, &iter); + while ((src_oid = oidset_iter_next(&iter))) + oidset_insert(dest, src_oid); +} + int oidset_remove(struct oidset *set, const struct object_id *oid) { khiter_t pos = kh_get_oid_set(&set->set, *oid); |