From: Karthik Nayak Date: Sat, 06 Jun 2015 13:48:15 GMT Subject: [PATCH v6 10/11] for-each-ref: introduce filter_refs() Message-ID: <1433598496-31287-10-git-send-email-karthik.188@gmail.com> In-Reply-To: <1433598496-31287-1-git-send-email-karthik.188@gmail.com> Introduce filter_refs() which will act as an API for users to call and provide a function which will iterate over a set of refs while filtering out the required refs. Currently this will wrap around ref_filter_handler(). Hence, ref_filter_handler is made file scope static. Helped-by: Junio C Hamano Mentored-by: Christian Couder Mentored-by: Matthieu Moy Signed-off-by: Karthik Nayak --- ref-filter.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ref-filter.c b/ref-filter.c index ece16a1..91a6ec9 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -904,6 +904,16 @@ void ref_array_clear(struct ref_array *array) array->nr = array->alloc = 0; } +/* + * API for filtering a set of refs. The refs are provided and iterated + * over using the for_each_ref_fn(). The refs are stored into and filtered + * based on the ref_filter_cbdata structure. + */ +int filter_refs(int (for_each_ref_fn)(each_ref_fn, void *), struct ref_filter_cbdata *data) +{ + return for_each_ref_fn(ref_filter_handler, data); +} + static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, struct ref_array_item *b) { struct atom_value *va, *vb; -- 2.4.2