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>
This commit is contained in:
Junio C Hamano
2025-11-20 11:45:35 -08:00
parent ce1a5a22a5
commit 0bd16856ff
6 changed files with 25 additions and 12 deletions

12
fsck.c
View File

@@ -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;
}