Merge branch 'jk/implicit-true'
Some codepaths did not correctly parse configuration variables specified with valueless "true", which has been corrected. * jk/implicit-true: fsck: handle NULL value when parsing message config trailer: handle NULL value when parsing trailer-specific config submodule: handle NULL value when parsing submodule.*.branch help: handle NULL value for alias.* config trace2: handle NULL values in tr2_sysenv config callback setup: handle NULL value when parsing extensions config: handle NULL value when parsing non-bools
This commit is contained in:
@ -748,6 +748,8 @@ static int git_blame_config(const char *var, const char *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(var, "blame.coloring")) {
|
if (!strcmp(var, "blame.coloring")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
if (!strcmp(value, "repeatedLines")) {
|
if (!strcmp(value, "repeatedLines")) {
|
||||||
coloring_mode |= OUTPUT_COLOR_LINE;
|
coloring_mode |= OUTPUT_COLOR_LINE;
|
||||||
} else if (!strcmp(value, "highlightRecent")) {
|
} else if (!strcmp(value, "highlightRecent")) {
|
||||||
|
@ -1202,6 +1202,8 @@ static int git_checkout_config(const char *var, const char *value,
|
|||||||
struct checkout_opts *opts = cb;
|
struct checkout_opts *opts = cb;
|
||||||
|
|
||||||
if (!strcmp(var, "diff.ignoresubmodules")) {
|
if (!strcmp(var, "diff.ignoresubmodules")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
handle_ignore_submodules_arg(&opts->diff_options, value);
|
handle_ignore_submodules_arg(&opts->diff_options, value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -791,6 +791,8 @@ static int git_clone_config(const char *k, const char *v,
|
|||||||
const struct config_context *ctx, void *cb)
|
const struct config_context *ctx, void *cb)
|
||||||
{
|
{
|
||||||
if (!strcmp(k, "clone.defaultremotename")) {
|
if (!strcmp(k, "clone.defaultremotename")) {
|
||||||
|
if (!v)
|
||||||
|
return config_error_nonbool(k);
|
||||||
free(remote_name);
|
free(remote_name);
|
||||||
remote_name = xstrdup(v);
|
remote_name = xstrdup(v);
|
||||||
}
|
}
|
||||||
|
@ -594,8 +594,11 @@ static int git_log_config(const char *var, const char *value,
|
|||||||
decoration_style = 0; /* maybe warn? */
|
decoration_style = 0; /* maybe warn? */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strcmp(var, "log.diffmerges"))
|
if (!strcmp(var, "log.diffmerges")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
return diff_merges_config(value);
|
return diff_merges_config(value);
|
||||||
|
}
|
||||||
if (!strcmp(var, "log.showroot")) {
|
if (!strcmp(var, "log.showroot")) {
|
||||||
default_show_root = git_config_bool(var, value);
|
default_show_root = git_config_bool(var, value);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3204,7 +3204,7 @@ static int git_pack_config(const char *k, const char *v,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strcmp(k, "uploadpack.blobpackfileuri")) {
|
if (!strcmp(k, "uploadpack.blobpackfileuri")) {
|
||||||
struct configured_exclusion *ex = xmalloc(sizeof(*ex));
|
struct configured_exclusion *ex;
|
||||||
const char *oid_end, *pack_end;
|
const char *oid_end, *pack_end;
|
||||||
/*
|
/*
|
||||||
* Stores the pack hash. This is not a true object ID, but is
|
* Stores the pack hash. This is not a true object ID, but is
|
||||||
@ -3212,6 +3212,10 @@ static int git_pack_config(const char *k, const char *v,
|
|||||||
*/
|
*/
|
||||||
struct object_id pack_hash;
|
struct object_id pack_hash;
|
||||||
|
|
||||||
|
if (!v)
|
||||||
|
return config_error_nonbool(k);
|
||||||
|
|
||||||
|
ex = xmalloc(sizeof(*ex));
|
||||||
if (parse_oid_hex(v, &ex->e.oid, &oid_end) ||
|
if (parse_oid_hex(v, &ex->e.oid, &oid_end) ||
|
||||||
*oid_end != ' ' ||
|
*oid_end != ' ' ||
|
||||||
parse_oid_hex(oid_end + 1, &pack_hash, &pack_end) ||
|
parse_oid_hex(oid_end + 1, &pack_hash, &pack_end) ||
|
||||||
|
@ -142,6 +142,7 @@ static enum deny_action parse_deny_action(const char *var, const char *value)
|
|||||||
static int receive_pack_config(const char *var, const char *value,
|
static int receive_pack_config(const char *var, const char *value,
|
||||||
const struct config_context *ctx, void *cb)
|
const struct config_context *ctx, void *cb)
|
||||||
{
|
{
|
||||||
|
const char *msg_id;
|
||||||
int status = parse_hide_refs_config(var, value, "receive", &hidden_refs);
|
int status = parse_hide_refs_config(var, value, "receive", &hidden_refs);
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
@ -178,12 +179,14 @@ static int receive_pack_config(const char *var, const char *value,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip_prefix(var, "receive.fsck.", &var)) {
|
if (skip_prefix(var, "receive.fsck.", &msg_id)) {
|
||||||
if (is_valid_msg_type(var, value))
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
|
if (is_valid_msg_type(msg_id, value))
|
||||||
strbuf_addf(&fsck_msg_types, "%c%s=%s",
|
strbuf_addf(&fsck_msg_types, "%c%s=%s",
|
||||||
fsck_msg_types.len ? ',' : '=', var, value);
|
fsck_msg_types.len ? ',' : '=', msg_id, value);
|
||||||
else
|
else
|
||||||
warning("skipping unknown msg id '%s'", var);
|
warning("skipping unknown msg id '%s'", msg_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,6 +255,8 @@ int mingw_core_config(const char *var, const char *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(var, "core.unsetenvvars")) {
|
if (!strcmp(var, "core.unsetenvvars")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
free(unset_environment_variables);
|
free(unset_environment_variables);
|
||||||
unset_environment_variables = xstrdup(value);
|
unset_environment_variables = xstrdup(value);
|
||||||
return 0;
|
return 0;
|
||||||
|
8
config.c
8
config.c
@ -1386,6 +1386,8 @@ static int git_default_core_config(const char *var, const char *value,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strcmp(var, "core.checkstat")) {
|
if (!strcmp(var, "core.checkstat")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
if (!strcasecmp(value, "default"))
|
if (!strcasecmp(value, "default"))
|
||||||
check_stat = 1;
|
check_stat = 1;
|
||||||
else if (!strcasecmp(value, "minimal"))
|
else if (!strcasecmp(value, "minimal"))
|
||||||
@ -1547,11 +1549,15 @@ static int git_default_core_config(const char *var, const char *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(var, "core.checkroundtripencoding")) {
|
if (!strcmp(var, "core.checkroundtripencoding")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
check_roundtrip_encoding = xstrdup(value);
|
check_roundtrip_encoding = xstrdup(value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(var, "core.notesref")) {
|
if (!strcmp(var, "core.notesref")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
notes_ref_name = xstrdup(value);
|
notes_ref_name = xstrdup(value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1619,6 +1625,8 @@ static int git_default_core_config(const char *var, const char *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(var, "core.createobject")) {
|
if (!strcmp(var, "core.createobject")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
if (!strcmp(value, "rename"))
|
if (!strcmp(value, "rename"))
|
||||||
object_creation_mode = OBJECT_CREATION_USES_RENAMES;
|
object_creation_mode = OBJECT_CREATION_USES_RENAMES;
|
||||||
else if (!strcmp(value, "link"))
|
else if (!strcmp(value, "link"))
|
||||||
|
19
diff.c
19
diff.c
@ -372,7 +372,10 @@ int git_diff_ui_config(const char *var, const char *value,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strcmp(var, "diff.colormovedws")) {
|
if (!strcmp(var, "diff.colormovedws")) {
|
||||||
unsigned cm = parse_color_moved_ws(value);
|
unsigned cm;
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
|
cm = parse_color_moved_ws(value);
|
||||||
if (cm & COLOR_MOVED_WS_ERROR)
|
if (cm & COLOR_MOVED_WS_ERROR)
|
||||||
return -1;
|
return -1;
|
||||||
diff_color_moved_ws_default = cm;
|
diff_color_moved_ws_default = cm;
|
||||||
@ -426,10 +429,15 @@ int git_diff_ui_config(const char *var, const char *value,
|
|||||||
if (!strcmp(var, "diff.orderfile"))
|
if (!strcmp(var, "diff.orderfile"))
|
||||||
return git_config_pathname(&diff_order_file_cfg, var, value);
|
return git_config_pathname(&diff_order_file_cfg, var, value);
|
||||||
|
|
||||||
if (!strcmp(var, "diff.ignoresubmodules"))
|
if (!strcmp(var, "diff.ignoresubmodules")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
handle_ignore_submodules_arg(&default_diff_options, value);
|
handle_ignore_submodules_arg(&default_diff_options, value);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(var, "diff.submodule")) {
|
if (!strcmp(var, "diff.submodule")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
if (parse_submodule_params(&default_diff_options, value))
|
if (parse_submodule_params(&default_diff_options, value))
|
||||||
warning(_("Unknown value for 'diff.submodule' config variable: '%s'"),
|
warning(_("Unknown value for 'diff.submodule' config variable: '%s'"),
|
||||||
value);
|
value);
|
||||||
@ -473,7 +481,10 @@ int git_diff_basic_config(const char *var, const char *value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(var, "diff.wserrorhighlight")) {
|
if (!strcmp(var, "diff.wserrorhighlight")) {
|
||||||
int val = parse_ws_error_highlight(value);
|
int val;
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
|
val = parse_ws_error_highlight(value);
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
return -1;
|
return -1;
|
||||||
ws_error_highlight_default = val;
|
ws_error_highlight_default = val;
|
||||||
@ -490,6 +501,8 @@ int git_diff_basic_config(const char *var, const char *value,
|
|||||||
|
|
||||||
if (!strcmp(var, "diff.dirstat")) {
|
if (!strcmp(var, "diff.dirstat")) {
|
||||||
struct strbuf errmsg = STRBUF_INIT;
|
struct strbuf errmsg = STRBUF_INIT;
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
default_diff_options.dirstat_permille = diff_dirstat_permille_default;
|
default_diff_options.dirstat_permille = diff_dirstat_permille_default;
|
||||||
if (parse_dirstat_params(&default_diff_options, value, &errmsg))
|
if (parse_dirstat_params(&default_diff_options, value, &errmsg))
|
||||||
warning(_("Found errors in 'diff.dirstat' config variable:\n%s"),
|
warning(_("Found errors in 'diff.dirstat' config variable:\n%s"),
|
||||||
|
12
fetch-pack.c
12
fetch-pack.c
@ -1862,6 +1862,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
|
|||||||
static int fetch_pack_config_cb(const char *var, const char *value,
|
static int fetch_pack_config_cb(const char *var, const char *value,
|
||||||
const struct config_context *ctx, void *cb)
|
const struct config_context *ctx, void *cb)
|
||||||
{
|
{
|
||||||
|
const char *msg_id;
|
||||||
|
|
||||||
if (strcmp(var, "fetch.fsck.skiplist") == 0) {
|
if (strcmp(var, "fetch.fsck.skiplist") == 0) {
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
@ -1873,12 +1875,14 @@ static int fetch_pack_config_cb(const char *var, const char *value,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip_prefix(var, "fetch.fsck.", &var)) {
|
if (skip_prefix(var, "fetch.fsck.", &msg_id)) {
|
||||||
if (is_valid_msg_type(var, value))
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
|
if (is_valid_msg_type(msg_id, value))
|
||||||
strbuf_addf(&fsck_msg_types, "%c%s=%s",
|
strbuf_addf(&fsck_msg_types, "%c%s=%s",
|
||||||
fsck_msg_types.len ? ',' : '=', var, value);
|
fsck_msg_types.len ? ',' : '=', msg_id, value);
|
||||||
else
|
else
|
||||||
warning("Skipping unknown msg id '%s'", var);
|
warning("Skipping unknown msg id '%s'", msg_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
fsck.c
8
fsck.c
@ -1403,6 +1403,8 @@ int git_fsck_config(const char *var, const char *value,
|
|||||||
const struct config_context *ctx, void *cb)
|
const struct config_context *ctx, void *cb)
|
||||||
{
|
{
|
||||||
struct fsck_options *options = cb;
|
struct fsck_options *options = cb;
|
||||||
|
const char *msg_id;
|
||||||
|
|
||||||
if (strcmp(var, "fsck.skiplist") == 0) {
|
if (strcmp(var, "fsck.skiplist") == 0) {
|
||||||
const char *path;
|
const char *path;
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
@ -1416,8 +1418,10 @@ int git_fsck_config(const char *var, const char *value,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip_prefix(var, "fsck.", &var)) {
|
if (skip_prefix(var, "fsck.", &msg_id)) {
|
||||||
fsck_set_msg_type(options, var, value);
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
|
fsck_set_msg_type(options, msg_id, value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
help.c
5
help.c
@ -464,8 +464,11 @@ static int get_alias(const char *var, const char *value,
|
|||||||
{
|
{
|
||||||
struct string_list *list = data;
|
struct string_list *list = data;
|
||||||
|
|
||||||
if (skip_prefix(var, "alias.", &var))
|
if (skip_prefix(var, "alias.", &var)) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
string_list_append(list, var)->util = xstrdup(value);
|
string_list_append(list, var)->util = xstrdup(value);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1253,6 +1253,8 @@ static int git_mailinfo_config(const char *var, const char *value,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!strcmp(var, "mailinfo.quotedcr")) {
|
if (!strcmp(var, "mailinfo.quotedcr")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
if (mailinfo_parse_quoted_cr_action(value, &mi->quoted_cr) != 0)
|
if (mailinfo_parse_quoted_cr_action(value, &mi->quoted_cr) != 0)
|
||||||
return error(_("bad action '%s' for '%s'"), value, var);
|
return error(_("bad action '%s' for '%s'"), value, var);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -112,6 +112,8 @@ static int notes_rewrite_config(const char *k, const char *v,
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!c->refs_from_env && !strcmp(k, "notes.rewriteref")) {
|
} else if (!c->refs_from_env && !strcmp(k, "notes.rewriteref")) {
|
||||||
|
if (!v)
|
||||||
|
return config_error_nonbool(k);
|
||||||
/* note that a refs/ prefix is implied in the
|
/* note that a refs/ prefix is implied in the
|
||||||
* underlying for_each_glob_ref */
|
* underlying for_each_glob_ref */
|
||||||
if (starts_with(v, "refs/notes/"))
|
if (starts_with(v, "refs/notes/"))
|
||||||
|
2
setup.c
2
setup.c
@ -559,6 +559,8 @@ static enum extension_result handle_extension_v0(const char *var,
|
|||||||
data->precious_objects = git_config_bool(var, value);
|
data->precious_objects = git_config_bool(var, value);
|
||||||
return EXTENSION_OK;
|
return EXTENSION_OK;
|
||||||
} else if (!strcmp(ext, "partialclone")) {
|
} else if (!strcmp(ext, "partialclone")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(var);
|
||||||
data->partial_clone = xstrdup(value);
|
data->partial_clone = xstrdup(value);
|
||||||
return EXTENSION_OK;
|
return EXTENSION_OK;
|
||||||
} else if (!strcmp(ext, "worktreeconfig")) {
|
} else if (!strcmp(ext, "worktreeconfig")) {
|
||||||
|
@ -516,7 +516,9 @@ static int parse_config(const char *var, const char *value,
|
|||||||
submodule->recommend_shallow =
|
submodule->recommend_shallow =
|
||||||
git_config_bool(var, value);
|
git_config_bool(var, value);
|
||||||
} else if (!strcmp(item.buf, "branch")) {
|
} else if (!strcmp(item.buf, "branch")) {
|
||||||
if (!me->overwrite && submodule->branch)
|
if (!value)
|
||||||
|
ret = config_error_nonbool(var);
|
||||||
|
else if (!me->overwrite && submodule->branch)
|
||||||
warn_multiple_config(me->treeish_name, submodule->name,
|
warn_multiple_config(me->treeish_name, submodule->name,
|
||||||
"branch");
|
"branch");
|
||||||
else {
|
else {
|
||||||
|
@ -68,6 +68,8 @@ static int tr2_sysenv_cb(const char *key, const char *value,
|
|||||||
|
|
||||||
for (k = 0; k < ARRAY_SIZE(tr2_sysenv_settings); k++) {
|
for (k = 0; k < ARRAY_SIZE(tr2_sysenv_settings); k++) {
|
||||||
if (!strcmp(key, tr2_sysenv_settings[k].git_config_name)) {
|
if (!strcmp(key, tr2_sysenv_settings[k].git_config_name)) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(key);
|
||||||
free(tr2_sysenv_settings[k].value);
|
free(tr2_sysenv_settings[k].value);
|
||||||
tr2_sysenv_settings[k].value = xstrdup(value);
|
tr2_sysenv_settings[k].value = xstrdup(value);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -507,6 +507,8 @@ static int git_trailer_default_config(const char *conf_key, const char *value,
|
|||||||
warning(_("unknown value '%s' for key '%s'"),
|
warning(_("unknown value '%s' for key '%s'"),
|
||||||
value, conf_key);
|
value, conf_key);
|
||||||
} else if (!strcmp(trailer_item, "separators")) {
|
} else if (!strcmp(trailer_item, "separators")) {
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(conf_key);
|
||||||
separators = xstrdup(value);
|
separators = xstrdup(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,16 +553,22 @@ static int git_trailer_config(const char *conf_key, const char *value,
|
|||||||
case TRAILER_KEY:
|
case TRAILER_KEY:
|
||||||
if (conf->key)
|
if (conf->key)
|
||||||
warning(_("more than one %s"), conf_key);
|
warning(_("more than one %s"), conf_key);
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(conf_key);
|
||||||
conf->key = xstrdup(value);
|
conf->key = xstrdup(value);
|
||||||
break;
|
break;
|
||||||
case TRAILER_COMMAND:
|
case TRAILER_COMMAND:
|
||||||
if (conf->command)
|
if (conf->command)
|
||||||
warning(_("more than one %s"), conf_key);
|
warning(_("more than one %s"), conf_key);
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(conf_key);
|
||||||
conf->command = xstrdup(value);
|
conf->command = xstrdup(value);
|
||||||
break;
|
break;
|
||||||
case TRAILER_CMD:
|
case TRAILER_CMD:
|
||||||
if (conf->cmd)
|
if (conf->cmd)
|
||||||
warning(_("more than one %s"), conf_key);
|
warning(_("more than one %s"), conf_key);
|
||||||
|
if (!value)
|
||||||
|
return config_error_nonbool(conf_key);
|
||||||
conf->cmd = xstrdup(value);
|
conf->cmd = xstrdup(value);
|
||||||
break;
|
break;
|
||||||
case TRAILER_WHERE:
|
case TRAILER_WHERE:
|
||||||
|
Reference in New Issue
Block a user