git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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);
Previous: Daniel BarkalowNext: Daniel Barkalow
Message 2 of 4 in “Keep '*' in pattern refspecs”
  1. 4/5 Keep '*' in pattern refspecsDaniel Barkalow, Mar 6, 2009
  2. Junio C HamanoMar 6, 2009
  3. Daniel BarkalowMar 6, 2009
  4. 4/5 Keep '*' in pattern refspecsDaniel Barkalow, Mar 7, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.