reflog: use parse_config_key in config callback
This doesn't save any lines, but does keep us from doing error-prone pointer arithmetic with constants. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4d5c6cefd5
commit
b3873c336c
@ -510,26 +510,27 @@ static int parse_expire_cfg_value(const char *var, const char *value, unsigned l
|
||||
|
||||
static int reflog_expire_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
const char *lastdot = strrchr(var, '.');
|
||||
const char *pattern, *key;
|
||||
int pattern_len;
|
||||
unsigned long expire;
|
||||
int slot;
|
||||
struct reflog_expire_cfg *ent;
|
||||
|
||||
if (!lastdot || prefixcmp(var, "gc."))
|
||||
if (parse_config_key(var, "gc", &pattern, &pattern_len, &key) < 0)
|
||||
return git_default_config(var, value, cb);
|
||||
|
||||
if (!strcmp(lastdot, ".reflogexpire")) {
|
||||
if (!strcmp(key, "reflogexpire")) {
|
||||
slot = EXPIRE_TOTAL;
|
||||
if (parse_expire_cfg_value(var, value, &expire))
|
||||
return -1;
|
||||
} else if (!strcmp(lastdot, ".reflogexpireunreachable")) {
|
||||
} else if (!strcmp(key, "reflogexpireunreachable")) {
|
||||
slot = EXPIRE_UNREACH;
|
||||
if (parse_expire_cfg_value(var, value, &expire))
|
||||
return -1;
|
||||
} else
|
||||
return git_default_config(var, value, cb);
|
||||
|
||||
if (lastdot == var + 2) {
|
||||
if (!pattern) {
|
||||
switch (slot) {
|
||||
case EXPIRE_TOTAL:
|
||||
default_reflog_expire = expire;
|
||||
@ -541,7 +542,7 @@ static int reflog_expire_config(const char *var, const char *value, void *cb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ent = find_cfg_ent(var + 3, lastdot - (var+3));
|
||||
ent = find_cfg_ent(pattern, pattern_len);
|
||||
if (!ent)
|
||||
return -1;
|
||||
switch (slot) {
|
||||
|
Loading…
Reference in New Issue
Block a user