From: Junio C Hamano Date: Mon, 20 Oct 2014 19:23:48 +0000 (-0700) Subject: Merge branch 'jn/parse-config-slot' X-Git-Tag: v2.2.0-rc0~37 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b94657683996402228abb1694a5db4792c424f9e?ds=inline Merge branch 'jn/parse-config-slot' Code cleanup. * jn/parse-config-slot: color_parse: do not mention variable name in error message pass config slots as pointers instead of offsets --- b94657683996402228abb1694a5db4792c424f9e diff --cc builtin/branch.c index 67850975e7,0a8ed9d22a..19a93a14d7 --- a/builtin/branch.c +++ b/builtin/branch.c @@@ -89,8 -87,8 +89,8 @@@ static int git_branch_config(const cha 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) diff --cc builtin/commit.c index 81dc622a3b,8dab44d933..60d35d0408 --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -1325,9 -1289,8 +1324,9 @@@ static int git_status_config(const cha 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) diff --cc builtin/log.c index 1202eba8b6,4c5fc4bff5..68d5d30035 --- a/builtin/log.c +++ b/builtin/log.c @@@ -390,8 -388,8 +390,8 @@@ static int git_log_config(const char *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; diff --cc pretty.c index a181ac6687,6182ca9aed..9d34d02db1 --- a/pretty.c +++ b/pretty.c @@@ -960,13 -974,13 +960,12 @@@ static size_t parse_color(struct strbu 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; }