From 0bd16856ffb3968de73699ad0555d1fae6c45406 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 20 Nov 2025 11:45:35 -0800 Subject: config: really treat missing optional path as not configured These callers expect that git_config_pathname() that returns 0 is a signal that the variable they passed has a string they need to act on. But with the introduction of ":(optional)path" earlier, that is no longer the case. If the path specified by the configuration variable is missing, their variable will get a NULL in it, and they need to act on it (often, just refraining from copying it elsewhere). Signed-off-by: Junio C Hamano --- gpg-interface.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gpg-interface.c') diff --git a/gpg-interface.c b/gpg-interface.c index 06e7fb5060..8b91a11a43 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -794,8 +794,16 @@ static int git_gpg_config(const char *var, const char *value, fmtname = "ssh"; if (fmtname) { + char *program; + int status; + fmt = get_format_by_name(fmtname); - return git_config_pathname((char **) &fmt->program, var, value); + status = git_config_pathname(&program, var, value); + if (status) + return status; + if (program) + fmt->program = program; + return status; } return 0; -- cgit v1.3-5-g9baa