static int drivers_alloc;
#define FUNCNAME(name, pattern) \
- { name, NULL, { pattern, REG_EXTENDED } }
+ { name, NULL, -1, { pattern, REG_EXTENDED } }
static struct userdiff_driver builtin_drivers[] = {
FUNCNAME("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$"),
FUNCNAME("java",
FUNCNAME("ruby", "^[ \t]*((class|module|def)[ \t].*)$"),
FUNCNAME("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$"),
FUNCNAME("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$"),
+{ "default", NULL, -1, { NULL, 0 } },
};
#undef FUNCNAME
static struct userdiff_driver driver_true = {
"diff=true",
NULL,
+ 0,
{ NULL, 0 }
};
-struct userdiff_driver *USERDIFF_ATTR_TRUE = &driver_true;
static struct userdiff_driver driver_false = {
"!diff",
NULL,
+ 1,
{ NULL, 0 }
};
-struct userdiff_driver *USERDIFF_ATTR_FALSE = &driver_false;
static struct userdiff_driver *userdiff_find_by_namelen(const char *k, int len)
{
drv = &drivers[ndrivers++];
memset(drv, 0, sizeof(*drv));
drv->name = xmemdupz(name, namelen);
+ drv->binary = -1;
}
return drv;
}
return 1;
}
-int userdiff_config_basic(const char *k, const char *v)
+static int parse_tristate(int *b, const char *k, const char *v)
+{
+ if (v && !strcasecmp(v, "auto"))
+ *b = -1;
+ else
+ *b = git_config_bool(k, v);
+ return 1;
+}
+
+int userdiff_config(const char *k, const char *v)
{
struct userdiff_driver *drv;
return parse_funcname(&drv->funcname, k, v, 0);
if ((drv = parse_driver(k, v, "xfuncname")))
return parse_funcname(&drv->funcname, k, v, REG_EXTENDED);
-
- return 0;
-}
-
-int userdiff_config_porcelain(const char *k, const char *v)
-{
- struct userdiff_driver *drv;
-
+ if ((drv = parse_driver(k, v, "binary")))
+ return parse_tristate(&drv->binary, k, v);
if ((drv = parse_driver(k, v, "command")))
return parse_string(&drv->external, k, v);
+ if ((drv = parse_driver(k, v, "textconv")))
+ return parse_string(&drv->textconv, k, v);
return 0;
}