Re: [PATCH v2 20/21] environment: stop storing "core.warnAmbiguousRefs" globally
- From
James Liu <james@jamesliu.io>
- Date
- Sep 4, 2024, 02:10 UTC
- Message-ID
- <D3X4VGA5L7JS.KX0H76M2YL2O@jamesliu.io>
- In-Reply-To
- <fc6fcebf7f737617c635b338e3c0dce10e77881c.1725008898.git.ps@pks.im>
On Fri Aug 30, 2024 at 7:09 PM AEST, Patrick Steinhardt wrote:
Show 13 quoted lines
> Same as the preceding commits, storing the "core.warnAmbiguousRefs" > value globally is misdesigned as this setting may be set per repository. > > Move the logic into the repo-settings subsystem. The usual pattern here > is that users are expected to call `prepare_repo_settings()` before they > access the settings themselves. This seems somewhat fragile though, as > it is easy to miss and leads to somewhat ugly code patterns at the call > sites. > > Instead, introduce a new function that encapsulates this logic for us. > This also allows us to change how exactly the lazy initialization works > in the future, e.g. by only partially initializing values as requested > by the caller.
Cool! `prepare_repo_settings()` is safe (and seems also reasonably cheap) to execute multiple times.