Re: [PATCH v3 5/9] ref-filter: add option to match literal pattern
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jul 22, 2015, 19:20 UTC
- Message-ID
- <vpqmvyongnf.fsf@anie.imag.fr>
- In-Reply-To
- <1437246749-14423-6-git-send-email-Karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 22 quoted lines
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -943,9 +943,23 @@ static int commit_contains(struct ref_filter *filter, struct commit *commit)
>
> /*
> * Return 1 if the refname matches one of the patterns, otherwise 0.
> + * A pattern can be a literal prefix (e.g. a refname "refs/heads/master"
> + * matches a pattern "refs/heads/m") or a wildcard (e.g. the same ref
> + * matches "refs/heads/m*", too).
> + */
> +static int match_pattern(const char **patterns, const char *refname)
> +{
> + for (; *patterns; patterns++)
> + if (!wildmatch(*patterns, refname, 0, NULL))
> + return 1;
> + return 0;
> +}
> +
> +/*
> + * Return 1 if the refname matches one of the patterns, otherwise 0.
> * A pattern can be path prefix (e.g. a refname "refs/heads/master"
> * matches a pattern "refs/heads/") or a wildcard (e.g. the same refWhile you're there, why not say explicitly
* A pattern can be path prefix (e.g. a refname "refs/heads/master"
* matches a pattern "refs/heads/" but not "refs/heads/m")
^^^^^^^^^^^^^^^^^^^^^^
...(I find it frustrating when the docstrings for two function look identical and I have to find out the 1-character difference to understand ...)
-- Matthieu Moy http://www-verimag.imag.fr/~moy/