X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=sha1-array.c;h=d922e94e3fc58488402ac0095075bf5ef0e4d17b;hb=04d67b6ab222060546af328207ad48ae8ad58fe9;hp=b94e0ec0f5e45fa56e1748bbb611a904ab81de67;hpb=6af9ca2436326fb0f2bad00b4a920921f82335f0;p=thirdparty%2Fgit.git diff --git a/sha1-array.c b/sha1-array.c index b94e0ec0f5..d922e94e3f 100644 --- a/sha1-array.c +++ b/sha1-array.c @@ -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; +}