Re: [PATCH v2 3/7] builtin/receive-pack: read unpack limit config lazily
Justin Tobler <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <anoi42_kmpc13Axd@denethor> |
On 26/08/10 10:54AM, Junio C Hamano wrote: > 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. Ya, as Patrick mentioned in [1], making it static probably isn't even really required because in practice we just check the unpack limit once. For now, it may just be sufficient to fetch the unpack limit value on demand. -Justin [1]: <[email protected]>