Subject: Re: [PATCH 1/7] add special "matching refs" refspec

From: Junio C Hamano <[email-masked]>
Date: Wed, 30 Apr 2008 02:23:53 -0700

Paolo Bonzini <[email-masked]> writes:

> @@ -937,13 +945,23 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
>  						 const struct ref *src)
>  {
>  	int i;
> +	int matching_refs = -1;
>  	for (i = 0; i < rs_nr; i++) {
> +		if (rs[i].matching &&
> +		    (matching_refs == -1 || rs[i].force)) {
> +			matching_refs = i;
> +			continue;
> +		}
> +
>  		if (rs[i].pattern &&
>  		    !prefixcmp(src->name, rs[i].src) &&
>  		    src->name[strlen(rs[i].src)] == '/')
>  			return rs + i;
>  	}
> -	return NULL;
> +	if (matching_refs != -1)
> +		return rs + matching_refs;
> +	else
> +		return NULL;
>  }

It is probably better to document that you would force if you have both
"+:" and ":" for the same remote, even though I am not sure if allowing
that (instead of diagnosing it as an error) is the right thing to do.

Is it an error to have both ":" and "some:other" refspecs for the same
remote?  If so who makes the check?

Otherwise this patch seems to be very cleanly done.  Especially I like how
the updated match_refs() looks.