From: Tian Yuchen <cat@malon.dev>
To: git@vger.kernel.org
Cc: cirnovskyv@gmail.com, szeder.dev@gmail.com,
Tian Yuchen <cat@malon.dev>,
Christian Couder <christian.couder@gmail.com>,
Ayush Chandekar <ayu.chandekar@gmail.com>,
Olamide Caleb Bello <belkid98@gmail.com>
Subject: [PATCH v7 5/9] environment: move askpass_program into repo_config_values
Date: Mon, 6 Jul 2026 22:25:26 +0800 [thread overview]
Message-ID: <20260706142530.3681520-6-cat@malon.dev> (raw)
In-Reply-To: <20260706142530.3681520-1-cat@malon.dev>
The global variable 'askpass_program' stores the path to the program
used to prompt the user for credentials. Move it into repo_config_values
to continue the libification effort.
While it is uncommon for a single process to require different askpass
programs for different repositories, maintaining this value as a mutable
global string is a blocker for libification. Global heap-allocated
strings introduce thread-safety issues in a multi-repo environment.
Move 'askpass_program' into 'struct repo_config_values' to eliminate
this global state. The memory is now safely managed and freed via
'repo_config_values_clear()'.
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Tian Yuchen <cat@malon.dev>
---
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 a1204fdcb2..3782bf68aa 100644
--- a/environment.c
+++ b/environment.c
@@ -462,8 +462,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);
}
if (!strcmp(var, "core.excludesfile")) {
@@ -724,6 +724,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;
@@ -756,4 +757,5 @@ void repo_config_values_clear(struct repository *repo)
FREE_AND_NULL(cfg->excludes_file);
FREE_AND_NULL(cfg->editor_program);
FREE_AND_NULL(cfg->pager_program);
+ FREE_AND_NULL(cfg->askpass_program);
}
diff --git a/environment.h b/environment.h
index 22f6697c52..d55b1ba073 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;
diff --git a/prompt.c b/prompt.c
index 706fba2a50..d8d74c7e37 100644
--- a/prompt.c
+++ b/prompt.c
@@ -3,6 +3,7 @@
#include "git-compat-util.h"
#include "parse.h"
#include "environment.h"
+#include "repository.h"
#include "run-command.h"
#include "strbuf.h"
#include "prompt.h"
@@ -51,7 +52,7 @@ char *git_prompt(const char *prompt, int flags)
askpass = getenv("GIT_ASKPASS");
if (!askpass)
- askpass = askpass_program;
+ askpass = repo_config_values(the_repository)->askpass_program;
if (!askpass)
askpass = getenv("SSH_ASKPASS");
if (askpass && *askpass)
--
2.43.0
next prev parent reply other threads:[~2026-07-06 14:26 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 7:50 [PATCH v2 0/2] environment: move excludes_file into repo_config_values Tian Yuchen
2026-06-26 7:50 ` [PATCH v2 1/2] dir: encapsulate excludes_file lazy-load Tian Yuchen
2026-06-26 21:14 ` SZEDER Gábor
2026-06-26 21:45 ` Junio C Hamano
2026-06-27 14:13 ` Tian Yuchen
2026-06-26 7:50 ` [PATCH v2 2/2] environment: move excludes_file into repo_config_values Tian Yuchen
2026-06-26 15:43 ` Junio C Hamano
2026-06-26 19:12 ` Junio C Hamano
2026-06-27 14:10 ` Tian Yuchen
2026-06-26 15:42 ` [PATCH v2 0/2] " Junio C Hamano
2026-06-27 13:56 ` Tian Yuchen
2026-06-27 16:08 ` [PATCH v4 0/1] " Tian Yuchen
2026-06-27 16:08 ` [PATCH v4 1/1] " Tian Yuchen
2026-06-27 16:10 ` Tian Yuchen
2026-06-27 20:47 ` Junio C Hamano
2026-06-28 3:19 ` Tian Yuchen
2026-06-28 3:38 ` Tian Yuchen
2026-06-28 8:40 ` Junio C Hamano
2026-06-28 12:58 ` Tian Yuchen
2026-06-29 6:03 ` Christian Couder
2026-06-29 14:47 ` Junio C Hamano
2026-06-30 16:20 ` Tian Yuchen
2026-07-01 18:14 ` Tian Yuchen
2026-06-30 16:44 ` [PATCH v5 0/1] " Tian Yuchen
2026-06-30 16:44 ` [PATCH v5 1/1] " Tian Yuchen
2026-07-01 18:08 ` [PATCH v6 0/1] " Tian Yuchen
2026-07-01 18:08 ` [PATCH v6 1/1] " Tian Yuchen
2026-07-06 14:25 ` [PATCH v7 0/9] migrate more variables " Tian Yuchen
2026-07-06 14:25 ` [PATCH v7 1/9] repository: introduce repo_config_values_clear() Tian Yuchen
2026-07-06 14:25 ` [PATCH v7 2/9] environment: move excludes_file into repo_config_values Tian Yuchen
2026-07-06 14:25 ` [PATCH v7 3/9] environment: move editor_program " Tian Yuchen
2026-07-06 14:25 ` [PATCH v7 4/9] environment: move pager_program " Tian Yuchen
2026-07-06 17:38 ` Junio C Hamano
2026-07-06 14:25 ` Tian Yuchen [this message]
2026-07-06 14:25 ` [PATCH v7 6/9] environment: migrate apply_default_whitespace and apply_default_ignorewhitespace Tian Yuchen
2026-07-06 14:25 ` [PATCH v7 7/9] environment: move push_default into repo_config_values Tian Yuchen
2026-07-06 14:25 ` [PATCH v7 8/9] environment: move autorebase " Tian Yuchen
2026-07-06 14:25 ` [PATCH v7 9/9] environment: move object_creation_mode " Tian Yuchen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260706142530.3681520-6-cat@malon.dev \
--to=cat@malon.dev \
--cc=ayu.chandekar@gmail.com \
--cc=belkid98@gmail.com \
--cc=christian.couder@gmail.com \
--cc=cirnovskyv@gmail.com \
--cc=git@vger.kernel.org \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox