Re: [PATCH v7 01/12] for-each-ref: extract helper functions out of grab_single_ref()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 12, 2015, 17:30 UTC
- Message-ID
- <xmqq616sesw7.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1434039003-10928-1-git-send-email-karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 29 quoted lines
> 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>
> ---
> 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"?