Re: [PATCH 4/5] Keep '*' in pattern refspecs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 6, 2009, 08:18 UTC
- Message-ID
- <7vsklrt66z.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <alpine.LNX.1.00.0903052355480.19665@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
Show 5 quoted lines
> In order to do anything more capable with refspecs, the first step is > to keep the entire input. Additionally, validate patterns by checking > for the ref matching the rules for a pattern as given by > check_ref_format(). This requires a slight change to make it require > the '*' to be at the beginning of a path component.
I had a brief "Huh?" moment wondering about this "slight change", but at this stage it does not change the rule at all ("/*" still must happen at the end of the string), so there actually is no change.
Show 12 quoted lines
> diff --git a/remote.c b/remote.c
> index 93fd03d..d0ce4c6 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -722,10 +716,10 @@ int remote_has_url(struct remote *remote, const char *url)
> static int name_fits_pattern(const char *key, const char *name,
> const char *value, char **result)
> {
> - size_t klen = strlen(key);
> - int ret = !strncmp(key, name, klen);
> + size_t klen = strchr(key, '*') - key;
> + int ret = !strncmp(name, key, klen);Any particular reason why the first parameters to strncmp() were swapped?
> if (ret && value) {
> - size_t vlen = strlen(value);
> + size_t vlen = strchr(value, '*') - value;We would want protection from programming error here, to catch keys and values without any asterisk. This comment also applies to [5/5].
> *result = xmalloc(vlen + > strlen(name) - > klen + 1);