repo-settings: introduce function to clear struct
We don't provide a way to clear a `struct repo_settings`, and instead open-code this in `repo_clear()`. This is mixing up concerns and means that developers have to touch multiple files whenever they add a new field to the structure in case the associated resources need to be released. Provide a new `repo_settings_clear()` function to improve this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
88dd321cfe
commit
b411ed60c7
@ -21,7 +21,6 @@ static void repo_cfg_int(struct repository *r, const char *key, int *dest,
|
||||
|
||||
void prepare_repo_settings(struct repository *r)
|
||||
{
|
||||
const struct repo_settings defaults = REPO_SETTINGS_INIT;
|
||||
int experimental;
|
||||
int value;
|
||||
const char *strval;
|
||||
@ -35,7 +34,7 @@ void prepare_repo_settings(struct repository *r)
|
||||
if (r->settings.initialized)
|
||||
return;
|
||||
|
||||
memcpy(&r->settings, &defaults, sizeof(defaults));
|
||||
repo_settings_clear(r);
|
||||
r->settings.initialized++;
|
||||
|
||||
/* Booleans config or default, cascades to other settings */
|
||||
@ -143,6 +142,13 @@ void prepare_repo_settings(struct repository *r)
|
||||
r->settings.packed_git_limit = ulongval;
|
||||
}
|
||||
|
||||
void repo_settings_clear(struct repository *r)
|
||||
{
|
||||
struct repo_settings empty = REPO_SETTINGS_INIT;
|
||||
FREE_AND_NULL(r->settings.fsmonitor);
|
||||
r->settings = empty;
|
||||
}
|
||||
|
||||
enum log_refs_config repo_settings_get_log_all_ref_updates(struct repository *repo)
|
||||
{
|
||||
const char *value;
|
||||
|
Reference in New Issue
Block a user