Re: [PATCH v2 3/7] builtin/receive-pack: read unpack limit config lazily
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 10, 2026, 17:54 UTC
- Message-ID
- <xmqqzeyt6ets.fsf@gitster.g>
- In-Reply-To
- <20260809190106.1565882-4-jltobler@gmail.com>
Justin Tobler <jltobler@gmail.com> writes:
Show 23 quoted lines
> +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.