| 455 | } |
| 456 | |
| 457 | int userdiff_config(const char *k, const char *v) |
| 458 | { |
| 459 | struct userdiff_driver *drv; |
| 460 | const char *name, *type; |
| 461 | size_t namelen; |
| 462 | |
| 463 | if (parse_config_key(k, "diff", &name, &namelen, &type) || !name) |
| 464 | return 0; |
| 465 | |
| 466 | drv = userdiff_find_by_namelen(name, namelen); |
| 467 | if (!drv) { |
| 468 | ALLOC_GROW(drivers, ndrivers+1, drivers_alloc); |
| 469 | drv = &drivers[ndrivers++]; |
| 470 | memset(drv, 0, sizeof(*drv)); |
| 471 | drv->name = xmemdupz(name, namelen); |
| 472 | drv->binary = -1; |
| 473 | } |
| 474 | |
| 475 | if (!strcmp(type, "funcname")) |
| 476 | return parse_funcname(&drv->funcname, k, v, 0); |
| 477 | if (!strcmp(type, "xfuncname")) |
| 478 | return parse_funcname(&drv->funcname, k, v, REG_EXTENDED); |
| 479 | if (!strcmp(type, "binary")) |
| 480 | return parse_tristate(&drv->binary, k, v); |
| 481 | if (!strcmp(type, "command")) { |
| 482 | FREE_AND_NULL(drv->external.cmd); |
| 483 | return git_config_string(&drv->external.cmd, k, v); |
| 484 | } |
| 485 | if (!strcmp(type, "trustexitcode")) { |
| 486 | drv->external.trust_exit_code = git_config_bool(k, v); |
| 487 | return 0; |
| 488 | } |
| 489 | if (!strcmp(type, "textconv")) { |
| 490 | int ret; |
| 491 | FREE_AND_NULL(drv->textconv_owned); |
| 492 | ret = git_config_string(&drv->textconv_owned, k, v); |
| 493 | drv->textconv = drv->textconv_owned; |
| 494 | return ret; |
| 495 | } |
| 496 | if (!strcmp(type, "cachetextconv")) |
| 497 | return parse_bool(&drv->textconv_want_cache, k, v); |
| 498 | if (!strcmp(type, "wordregex")) { |
| 499 | int ret; |
| 500 | FREE_AND_NULL(drv->word_regex_owned); |
| 501 | ret = git_config_string(&drv->word_regex_owned, k, v); |
| 502 | drv->word_regex = drv->word_regex_owned; |
| 503 | return ret; |
| 504 | } |
| 505 | if (!strcmp(type, "algorithm")) { |
| 506 | int ret; |
| 507 | FREE_AND_NULL(drv->algorithm_owned); |
| 508 | ret = git_config_string(&drv->algorithm_owned, k, v); |
| 509 | drv->algorithm = drv->algorithm_owned; |
| 510 | return ret; |
| 511 | } |
| 512 | |
| 513 | return 0; |
| 514 | } |