Subject: Re: [PATCH v7 01/12] for-each-ref: extract helper functions out of grab_single_ref()

From: Junio C Hamano <[email-masked]>
Date: Fri, 12 Jun 2015 10:30:32 -0700

Karthik Nayak <[email-masked]> writes:

> 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 <[email-masked]>
> Mentored-by: Christian Couder <[email-masked]>
> Mentored-by: Matthieu Moy <[email-masked]>
> Signed-off-by: Karthik Nayak <[email-masked]>
> ---
>  builtin/for-each-ref.c | 64 ++++++++++++++++++++++++++++++++------------------
>  1 file changed, 41 insertions(+), 23 deletions(-)
>
> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
> index f7e51a7..67c8b62 100644
> --- a/builtin/for-each-ref.c
> +++ b/builtin/for-each-ref.c
> @@ -851,6 +851,44 @@ struct grab_ref_cbdata {
>  };
>  
>  /*
> + * Return 1 if the refname matches with one of the patterns,

s/with //;

> + * otherwise 0.  The patterns can be literal prefix (e.g. a
> + * refname "refs/heads/master" matches a pattern "refs/heads/")
> + * or a wildcard (e.g. the same ref matches "refs/heads/m*",too).
> + */

I know this was my bad suggestion, but "refs/heads/m" can be thought
of as a "literal prefix" that may match "refs/heads/master"; we do
not want to make that match, so perhaps "literal" is a bad way to
say this.  "A pattern can be a path prefix or a worldcard"?