aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-11-20 11:45:35 -0800
committerJunio C Hamano <gitster@pobox.com>2025-11-24 17:00:47 -0800
commit0bd16856ffb3968de73699ad0555d1fae6c45406 (patch)
tree9d2c78d62c1e4588bd54ae78a59205747af6500c
parentce1a5a22a5beefac8a52da518855b5aecc562874 (diff)
downloadgit-0bd16856ffb3968de73699ad0555d1fae6c45406.tar.xz
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 <gitster@pobox.com>
-rw-r--r--builtin/blame.c3
-rw-r--r--builtin/receive-pack.c5
-rw-r--r--fetch-pack.c5
-rw-r--r--fsck.c12
-rw-r--r--gpg-interface.c10
-rw-r--r--setup.c2
6 files changed, 25 insertions, 12 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index 5b10e84b66..1092834144 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -739,7 +739,8 @@ static int git_blame_config(const char *var, const char *value,
ret = git_config_pathname(&str, var, value);
if (ret)
return ret;
- string_list_insert(&ignore_revs_file_list, str);
+ if (str)
+ string_list_insert(&ignore_revs_file_list, str);
free(str);
return 0;
}
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 1113137a6f..4718573354 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -177,8 +177,9 @@ static int receive_pack_config(const char *var, const char *value,
if (git_config_pathname(&path, var, value))
return -1;
- strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
- fsck_msg_types.len ? ',' : '=', path);
+ if (path)
+ strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
+ fsck_msg_types.len ? ',' : '=', path);
free(path);
return 0;
}
diff --git a/fetch-pack.c b/fetch-pack.c
index 46c39f85c4..33a3f20bfc 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1872,8 +1872,9 @@ int fetch_pack_fsck_config(const char *var, const char *value,
if (git_config_pathname(&path, var, value))
return -1;
- strbuf_addf(msg_types, "%cskiplist=%s",
- msg_types->len ? ',' : '=', path);
+ if (path)
+ strbuf_addf(msg_types, "%cskiplist=%s",
+ msg_types->len ? ',' : '=', path);
free(path);
return 0;
}
diff --git a/fsck.c b/fsck.c
index 171b424dd5..0c287699d2 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1351,14 +1351,16 @@ int git_fsck_config(const char *var, const char *value,
if (strcmp(var, "fsck.skiplist") == 0) {
char *path;
- struct strbuf sb = STRBUF_INIT;
if (git_config_pathname(&path, var, value))
return -1;
- strbuf_addf(&sb, "skiplist=%s", path);
- free(path);
- fsck_set_msg_types(options, sb.buf);
- strbuf_release(&sb);
+ if (path) {
+ struct strbuf sb = STRBUF_INIT;
+ strbuf_addf(&sb, "skiplist=%s", path);
+ free(path);
+ fsck_set_msg_types(options, sb.buf);
+ strbuf_release(&sb);
+ }
return 0;
}
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;
diff --git a/setup.c b/setup.c
index 98ddbf377f..18301b5907 100644
--- a/setup.c
+++ b/setup.c
@@ -1248,7 +1248,7 @@ static int safe_directory_cb(const char *key, const char *value,
} else {
char *allowed = NULL;
- if (!git_config_pathname(&allowed, key, value)) {
+ if (!git_config_pathname(&allowed, key, value) && allowed) {
char *normalized = NULL;
/*