From: Junio C Hamano Date: Sun, 12 Jul 2026 15:47:02 GMT Subject: Re: [PATCH v10 5/9] environment: move askpass_program into repo_config_values Message-ID: In-Reply-To: <20260712111734.1073514-6-cat@malon.dev> Tian Yuchen writes: > environment.c | 6 ++++-- > environment.h | 1 + > prompt.c | 3 ++- > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/environment.c b/environment.c > index 975c9cb9eb..1a26c9c6d6 100644 > --- a/environment.c > +++ b/environment.c > @@ -464,8 +464,8 @@ int git_default_core_config(const char *var, const char *value, > } > > if (!strcmp(var, "core.askpass")) { > - FREE_AND_NULL(askpass_program); > - return git_config_string(&askpass_program, var, value); > + FREE_AND_NULL(cfg->askpass_program); > + return git_config_string(&cfg->askpass_program, var, value); > } > @@ -726,6 +726,7 @@ void repo_config_values_init(struct repo_config_values *cfg) > cfg->excludes_file = NULL; > cfg->editor_program = NULL; > cfg->pager_program = NULL; > + cfg->askpass_program = NULL; > cfg->apply_sparse_checkout = 0; > cfg->branch_track = BRANCH_TRACK_REMOTE; > cfg->trust_ctime = 1; > @@ -744,4 +745,5 @@ void repo_config_values_clear(struct repo_config_values *cfg) > FREE_AND_NULL(cfg->excludes_file); > FREE_AND_NULL(cfg->editor_program); > FREE_AND_NULL(cfg->pager_program); > + FREE_AND_NULL(cfg->askpass_program); > } The 'askpass_program' global variable has been removed. Instead, the member in repo_config_values is correctly initialized to NULL and properly cleaned up when finished. > diff --git a/environment.h b/environment.h > index 39b6691b47..a2e9def89d 100644 > --- a/environment.h > +++ b/environment.h > @@ -93,6 +93,7 @@ struct repo_config_values { > char *excludes_file; > char *editor_program; > char *pager_program; > + char *askpass_program; > int apply_sparse_checkout; > int trust_ctime; > int check_stat; Wait, wasn't there an extern declaration for that global variable in a header file somewhere? There must also be an actual definition for it. Both should be removed to ensure no one accesses a stale variable; doing so allows the compiler to help you spot any leftover users. Thanks.