diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-11-20 11:40:29 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-11-20 11:40:29 -0800 |
commit | 62ce40d9338046a89de5d2bfb6b258872fd366c0 (patch) | |
tree | caec918aacac7203a8d8c25145b412b9fed6a8cc /builtin/branch.c | |
parent | t4026: test "normal" color (diff) | |
parent | color_parse: do not mention variable name in error message (diff) | |
download | tgif-62ce40d9338046a89de5d2bfb6b258872fd366c0.tar.xz |
Merge branch 'jn/parse-config-slot' into jk/colors
* jn/parse-config-slot:
color_parse: do not mention variable name in error message
pass config slots as pointers instead of offsets
Diffstat (limited to 'builtin/branch.c')
-rw-r--r-- | builtin/branch.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index 0591b22a48..0a8ed9d22a 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -62,19 +62,19 @@ static unsigned char merge_filter_ref[20]; static struct string_list output = STRING_LIST_INIT_DUP; static unsigned int colopts; -static int parse_branch_color_slot(const char *var, int ofs) +static int parse_branch_color_slot(const char *slot) { - if (!strcasecmp(var+ofs, "plain")) + if (!strcasecmp(slot, "plain")) return BRANCH_COLOR_PLAIN; - if (!strcasecmp(var+ofs, "reset")) + if (!strcasecmp(slot, "reset")) return BRANCH_COLOR_RESET; - if (!strcasecmp(var+ofs, "remote")) + if (!strcasecmp(slot, "remote")) return BRANCH_COLOR_REMOTE; - if (!strcasecmp(var+ofs, "local")) + if (!strcasecmp(slot, "local")) return BRANCH_COLOR_LOCAL; - if (!strcasecmp(var+ofs, "current")) + if (!strcasecmp(slot, "current")) return BRANCH_COLOR_CURRENT; - if (!strcasecmp(var+ofs, "upstream")) + if (!strcasecmp(slot, "upstream")) return BRANCH_COLOR_UPSTREAM; return -1; } @@ -88,13 +88,12 @@ static int git_branch_config(const char *var, const char *value, void *cb) return 0; } if (starts_with(var, "color.branch.")) { - int slot = parse_branch_color_slot(var, 13); + int slot = parse_branch_color_slot(var + 13); if (slot < 0) return 0; if (!value) return config_error_nonbool(var); - color_parse(value, var, branch_colors[slot]); - return 0; + return color_parse(value, branch_colors[slot]); } return git_color_default_config(var, value, cb); } |