Re: [PATCH v6 1/4] config: add support for http.<url>.* settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Kyle J. McKay" <mackyle@xxxxxxxxx> writes:

> +static size_t http_option_max_matched_len[OPT_MAX];
>  ...
> +static int new_match_is_shorter(size_t matchlen, enum http_option_type opt)
> +{
> +	/*
> +	 * Compare matchlen to the last matched length of option opt and
> +	 * return true if matchlen is shorter than the last matched length
> +	 * (meaning the config setting should be ignored).  Upon seeing the
> +	 * _same_ key (i.e. new key has the same match length which is therefore
> +	 * not shorter) the new setting will override the previous setting.
> +	 * Otherwise return false and record matchlen as the current last
> +	 * matched length of option opt.
> +	 */
> +	if (matchlen < http_option_max_matched_len[opt])
> +		return 1;
> +	http_option_max_matched_len[opt] = matchlen;
> +	return 0;
> +}
> + ...
> @@ -337,7 +472,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
>  
>  	http_is_verbose = 0;
>  
> -	git_config(http_options, NULL);
> +	git_config(http_options, (void *)url);

Can http_init() be called more than once?  max-matched-len (and
leter user-matched as well) is initialized to zero at the link time,
and never reset after it is used for matching the configuration file
entries with a single URL.

If this function is called more than once, the code needs to
memset(0) the array(s), don't it?

Another possibility, which might be better, is to package that array
and the url into a structure, have it on the stackframe of this
function, i.e.

	struct match_url_state {
        	const char *url;

		size_t http_option_max_matched_len[OPT_MAX];
		int http_option_user_matched[OPT_MAX];
	} match_url_state = {NULL};

	git_config(http_options, &match_url_state);

or something.  In any case, you no longer have to cast the second
parameter of git_config to (void *) only to defeat constness ;-)

>  	curl_global_init(CURL_GLOBAL_ALL);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]