[PATCH v6 10/11] for-each-ref: introduce filter_refs()
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Jun 6, 2015, 13:48 UTC
- 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 <gitster@pobox.com> Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> --- 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