Re: [PATCH v2 3/7] builtin/receive-pack: read unpack limit config lazily

Junio C Hamano <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
Justin Tobler <[email protected]> writes:

> +static int get_unpack_limit(struct repository *repo)
> +{
> +	static int limit = -1;
> +
> +	if (limit < 0) {
> +		int receive_limit = -1;
> +		int transfer_limit = -1;
> +
> +		repo_config_get_int(repo, "receive.unpacklimit",
> +				    &receive_limit);
> +		repo_config_get_int(repo, "transfer.unpacklimit",
> +				    &transfer_limit);
> +
> +		if (receive_limit >= 0)
> +			limit = receive_limit;
> +		else if (transfer_limit >= 0)
> +			limit = transfer_limit;
> +		else
> +			limit = 100;
> +	}
> +
> +	return limit;
> +}

I am not sure whether this is progress.

A function that defines a 'static int' internally and sets it only
once is akin to using a global variable.  I wonder whether it would
be too much work to add a new member to either 'repo->settings' or
'repo->config_values' to make the setting truly per-repository.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.