From: Junio C Hamano Date: Fri, 06 Mar 2009 08:18:44 GMT Subject: Re: [PATCH 4/5] Keep '*' in pattern refspecs Message-ID: <7vsklrt66z.fsf@gitster.siamese.dyndns.org> In-Reply-To: Daniel Barkalow writes: > 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. > 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);