Code cleanup.
* jn/parse-config-slot:
color_parse: do not mention variable name in error message
pass config slots as pointers instead of offsets
branch_use_color = git_config_colorbool(var, value);
return 0;
}
- if (starts_with(var, "color.branch.")) {
- int slot = parse_branch_color_slot(var + 13);
+ if (skip_prefix(var, "color.branch.", &slot_name)) {
- int slot = parse_branch_color_slot(var, slot_name - var);
++ int slot = parse_branch_color_slot(slot_name);
if (slot < 0)
return 0;
if (!value)
s->display_comment_prefix = git_config_bool(k, v);
return 0;
}
- if (starts_with(k, "status.color.") || starts_with(k, "color.status.")) {
- int slot = parse_status_slot(k + 13);
+ if (skip_prefix(k, "status.color.", &slot_name) ||
+ skip_prefix(k, "color.status.", &slot_name)) {
- int slot = parse_status_slot(k, slot_name - k);
++ int slot = parse_status_slot(slot_name);
if (slot < 0)
return 0;
if (!v)
default_show_root = git_config_bool(var, value);
return 0;
}
- if (starts_with(var, "color.decorate."))
- return parse_decorate_color_config(var, var + 15, value);
+ if (skip_prefix(var, "color.decorate.", &slot_name))
- return parse_decorate_color_config(var, slot_name - var, value);
++ return parse_decorate_color_config(var, slot_name, value);
if (!strcmp(var, "log.mailmap")) {
use_mailmap_config = git_config_bool(var, value);
return 0;
if (!end)
return 0;
- if (starts_with(begin, "auto,")) {
+ if (skip_prefix(begin, "auto,", &begin)) {
if (!want_color(c->pretty_ctx->color))
return end - placeholder + 1;
- begin += 5;
}
- color_parse_mem(begin,
- end - begin,
- "--pretty format", color);
+ if (color_parse_mem(begin, end - begin, color) < 0)
+ die(_("unable to parse --pretty format"));
strbuf_addstr(sb, color);
return end - placeholder + 1;
}