Skip to content

Commit

Permalink
reflog: use parse_config_key in config callback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jan 23, 2013
1 parent 4d5c6ce commit b3873c3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions builtin/reflog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit b3873c3

Please sign in to comment.