Merge branch 'jk/userdiff-config-simplify'

* jk/userdiff-config-simplify:
  drop odd return value semantics from userdiff_config
This commit is contained in:
Junio C Hamano 2012-02-14 12:57:17 -08:00
commit 63d37c3062
5 changed files with 12 additions and 37 deletions

View file

@ -2050,14 +2050,8 @@ static int git_blame_config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
switch (userdiff_config(var, value)) { if (userdiff_config(var, value) < 0)
case 0:
break;
case -1:
return -1; return -1;
default:
return 0;
}
return git_default_config(var, value, cb); return git_default_config(var, value, cb);
} }

View file

@ -226,14 +226,8 @@ static const char * const cat_file_usage[] = {
static int git_cat_file_config(const char *var, const char *value, void *cb) static int git_cat_file_config(const char *var, const char *value, void *cb)
{ {
switch (userdiff_config(var, value)) { if (userdiff_config(var, value) < 0)
case 0:
break;
case -1:
return -1; return -1;
default:
return 0;
}
return git_default_config(var, value, cb); return git_default_config(var, value, cb);
} }

View file

@ -325,11 +325,8 @@ static int grep_config(const char *var, const char *value, void *cb)
struct grep_opt *opt = cb; struct grep_opt *opt = cb;
char *color = NULL; char *color = NULL;
switch (userdiff_config(var, value)) { if (userdiff_config(var, value) < 0)
case 0: break; return -1;
case -1: return -1;
default: return 0;
}
if (!strcmp(var, "grep.extendedregexp")) { if (!strcmp(var, "grep.extendedregexp")) {
if (git_config_bool(var, value)) if (git_config_bool(var, value))

7
diff.c
View file

@ -177,11 +177,8 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
return 0; return 0;
} }
switch (userdiff_config(var, value)) { if (userdiff_config(var, value) < 0)
case 0: break; return -1;
case -1: return -1;
default: return 0;
}
if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) { if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
int slot = parse_diff_color_slot(var, 11); int slot = parse_diff_color_slot(var, 11);

View file

@ -210,14 +210,7 @@ static int parse_funcname(struct userdiff_funcname *f, const char *k,
if (git_config_string(&f->pattern, k, v) < 0) if (git_config_string(&f->pattern, k, v) < 0)
return -1; return -1;
f->cflags = cflags; f->cflags = cflags;
return 1; return 0;
}
static int parse_string(const char **d, const char *k, const char *v)
{
if (git_config_string(d, k, v) < 0)
return -1;
return 1;
} }
static int parse_tristate(int *b, const char *k, const char *v) static int parse_tristate(int *b, const char *k, const char *v)
@ -226,13 +219,13 @@ static int parse_tristate(int *b, const char *k, const char *v)
*b = -1; *b = -1;
else else
*b = git_config_bool(k, v); *b = git_config_bool(k, v);
return 1; return 0;
} }
static int parse_bool(int *b, const char *k, const char *v) static int parse_bool(int *b, const char *k, const char *v)
{ {
*b = git_config_bool(k, v); *b = git_config_bool(k, v);
return 1; return 0;
} }
int userdiff_config(const char *k, const char *v) int userdiff_config(const char *k, const char *v)
@ -246,13 +239,13 @@ int userdiff_config(const char *k, const char *v)
if ((drv = parse_driver(k, v, "binary"))) if ((drv = parse_driver(k, v, "binary")))
return parse_tristate(&drv->binary, k, v); return parse_tristate(&drv->binary, k, v);
if ((drv = parse_driver(k, v, "command"))) if ((drv = parse_driver(k, v, "command")))
return parse_string(&drv->external, k, v); return git_config_string(&drv->external, k, v);
if ((drv = parse_driver(k, v, "textconv"))) if ((drv = parse_driver(k, v, "textconv")))
return parse_string(&drv->textconv, k, v); return git_config_string(&drv->textconv, k, v);
if ((drv = parse_driver(k, v, "cachetextconv"))) if ((drv = parse_driver(k, v, "cachetextconv")))
return parse_bool(&drv->textconv_want_cache, k, v); return parse_bool(&drv->textconv_want_cache, k, v);
if ((drv = parse_driver(k, v, "wordregex"))) if ((drv = parse_driver(k, v, "wordregex")))
return parse_string(&drv->word_regex, k, v); return git_config_string(&drv->word_regex, k, v);
return 0; return 0;
} }