mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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:
@@ -739,7 +739,8 @@ static int git_blame_config(const char *var, const char *value,
|
|||||||
ret = git_config_pathname(&str, var, value);
|
ret = git_config_pathname(&str, var, value);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
string_list_insert(&ignore_revs_file_list, str);
|
if (str)
|
||||||
|
string_list_insert(&ignore_revs_file_list, str);
|
||||||
free(str);
|
free(str);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,8 +177,9 @@ static int receive_pack_config(const char *var, const char *value,
|
|||||||
|
|
||||||
if (git_config_pathname(&path, var, value))
|
if (git_config_pathname(&path, var, value))
|
||||||
return -1;
|
return -1;
|
||||||
strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
|
if (path)
|
||||||
fsck_msg_types.len ? ',' : '=', path);
|
strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
|
||||||
|
fsck_msg_types.len ? ',' : '=', path);
|
||||||
free(path);
|
free(path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1872,8 +1872,9 @@ int fetch_pack_fsck_config(const char *var, const char *value,
|
|||||||
|
|
||||||
if (git_config_pathname(&path, var, value))
|
if (git_config_pathname(&path, var, value))
|
||||||
return -1;
|
return -1;
|
||||||
strbuf_addf(msg_types, "%cskiplist=%s",
|
if (path)
|
||||||
msg_types->len ? ',' : '=', path);
|
strbuf_addf(msg_types, "%cskiplist=%s",
|
||||||
|
msg_types->len ? ',' : '=', path);
|
||||||
free(path);
|
free(path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
12
fsck.c
12
fsck.c
@@ -1351,14 +1351,16 @@ int git_fsck_config(const char *var, const char *value,
|
|||||||
|
|
||||||
if (strcmp(var, "fsck.skiplist") == 0) {
|
if (strcmp(var, "fsck.skiplist") == 0) {
|
||||||
char *path;
|
char *path;
|
||||||
struct strbuf sb = STRBUF_INIT;
|
|
||||||
|
|
||||||
if (git_config_pathname(&path, var, value))
|
if (git_config_pathname(&path, var, value))
|
||||||
return -1;
|
return -1;
|
||||||
strbuf_addf(&sb, "skiplist=%s", path);
|
if (path) {
|
||||||
free(path);
|
struct strbuf sb = STRBUF_INIT;
|
||||||
fsck_set_msg_types(options, sb.buf);
|
strbuf_addf(&sb, "skiplist=%s", path);
|
||||||
strbuf_release(&sb);
|
free(path);
|
||||||
|
fsck_set_msg_types(options, sb.buf);
|
||||||
|
strbuf_release(&sb);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -794,8 +794,16 @@ static int git_gpg_config(const char *var, const char *value,
|
|||||||
fmtname = "ssh";
|
fmtname = "ssh";
|
||||||
|
|
||||||
if (fmtname) {
|
if (fmtname) {
|
||||||
|
char *program;
|
||||||
|
int status;
|
||||||
|
|
||||||
fmt = get_format_by_name(fmtname);
|
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;
|
return 0;
|
||||||
|
|||||||
2
setup.c
2
setup.c
@@ -1248,7 +1248,7 @@ static int safe_directory_cb(const char *key, const char *value,
|
|||||||
} else {
|
} else {
|
||||||
char *allowed = NULL;
|
char *allowed = NULL;
|
||||||
|
|
||||||
if (!git_config_pathname(&allowed, key, value)) {
|
if (!git_config_pathname(&allowed, key, value) && allowed) {
|
||||||
char *normalized = NULL;
|
char *normalized = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user