diff options
Diffstat (limited to 'sha1-array.c')
-rw-r--r-- | sha1-array.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sha1-array.c b/sha1-array.c index b94e0ec0f5..3eeadfede9 100644 --- a/sha1-array.c +++ b/sha1-array.c @@ -48,7 +48,7 @@ int oid_array_for_each(struct oid_array *array, { int i; - /* No oid_array_sort() here! See the api-oid-array.txt docs! */ + /* No oid_array_sort() here! See sha1-array.h */ for (i = 0; i < array->nr; i++) { int ret = fn(array->oid + i, data); @@ -77,3 +77,20 @@ int oid_array_for_each_unique(struct oid_array *array, } return 0; } + +void oid_array_filter(struct oid_array *array, + for_each_oid_fn want, + void *cb_data) +{ + unsigned nr = array->nr, src, dst; + struct object_id *oids = array->oid; + + for (src = dst = 0; src < nr; src++) { + if (want(&oids[src], cb_data)) { + if (src != dst) + oidcpy(&oids[dst], &oids[src]); + dst++; + } + } + array->nr = dst; +} |