for-each-ref: extract helper functions out of grab_single_ref()
commited01e206ba53a52d0094abcd9f99237b4e2847c9
authorKarthik Nayak <karthik.188@gmail.com>
Sat, 13 Jun 2015 19:37:19 +0000 (14 01:07 +0530)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jun 2015 18:48:07 +0000 (15 11:48 -0700)
treec63a8e2a2be4106d06bdb90fffd91ce5e9c9d007
parenta5fe66802f8c4036badd54ff36ff327d43236e7e
for-each-ref: extract helper functions out of grab_single_ref()

Extract two helper functions out of grab_single_ref(). Firstly,
new_refinfo() which is used to allocate memory for a new refinfo
structure and copy the objectname, refname and flag to it.
Secondly, match_name_as_path() which when given an array of patterns
and the refname checks if the refname matches any of the patterns
given while the pattern is a pathname, also supports wildcard
characters.

This is a preperatory patch for restructuring 'for-each-ref' and
eventually moving most of it to 'ref-filter' to provide the
functionality to similar commands via public API's.

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>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/for-each-ref.c