diff.c: guard config parser from value=NULL

diff.external, diff.*.command, diff.color.*, color.diff.* and
diff.*.funcname configuration variables expect a string value.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2008-02-11 10:53:56 -08:00
parent a7269e5cb7
commit 64f30e948b

14
diff.c
View File

@ -158,6 +158,8 @@ int git_diff_ui_config(const char *var, const char *value)
return 0;
}
if (!strcmp(var, "diff.external")) {
if (!value)
return config_error_nonbool(var);
external_diff_cmd_cfg = xstrdup(value);
return 0;
}
@ -165,10 +167,13 @@ int git_diff_ui_config(const char *var, const char *value)
const char *ep = strrchr(var, '.');
if (ep != var + 4) {
if (!strcmp(ep, ".command"))
if (!strcmp(ep, ".command")) {
if (!value)
return config_error_nonbool(var);
return parse_lldiff_command(var, ep, value);
}
}
}
return git_diff_basic_config(var, value);
}
@ -177,6 +182,8 @@ int git_diff_basic_config(const char *var, const char *value)
{
if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
int slot = parse_diff_color_slot(var, 11);
if (!value)
return config_error_nonbool(var);
color_parse(value, var, diff_colors[slot]);
return 0;
}
@ -184,10 +191,13 @@ int git_diff_basic_config(const char *var, const char *value)
if (!prefixcmp(var, "diff.")) {
const char *ep = strrchr(var, '.');
if (ep != var + 4) {
if (!strcmp(ep, ".funcname"))
if (!strcmp(ep, ".funcname")) {
if (!value)
return config_error_nonbool(var);
return parse_funcname_pattern(var, ep, value);
}
}
}
return git_default_config(var, value);
}