pass config slots as pointers instead of offsets

Many config-parsing helpers, like parse_branch_color_slot,
take the name of a config variable and an offset to the
"slot" name (e.g., "color.branch.plain" is passed along with
"13" to effectively pass "plain"). This is leftover from the
time that these functions would die() on error, and would
want the full variable name for error reporting.

These days they do not use the full variable name at all.
Passing a single pointer to the slot name is more natural,
and lets us more easily adjust the callers to use skip_prefix
to avoid manually writing offset numbers.

This is effectively a continuation of 9e1a5eb, which did the
same for parse_diff_color_slot. This patch covers all of the
remaining similar constructs.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jonathan Nieder
2014-10-07 15:16:57 -04:00
committed by Junio C Hamano
parent 80b616d04b
commit 8852117a60
5 changed files with 21 additions and 22 deletions

View File

@ -66,9 +66,9 @@ static int parse_decorate_color_slot(const char *slot)
return -1;
}
int parse_decorate_color_config(const char *var, const int ofs, const char *value)
int parse_decorate_color_config(const char *var, const char *slot_name, const char *value)
{
int slot = parse_decorate_color_slot(var + ofs);
int slot = parse_decorate_color_slot(slot_name);
if (slot < 0)
return 0;
if (!value)