| 517 | } |
| 518 | |
| 519 | static int git_trailer_config(const char *conf_key, const char *value, |
| 520 | const struct config_context *ctx UNUSED, |
| 521 | void *cb UNUSED) |
| 522 | { |
| 523 | const char *trailer_item, *variable_name; |
| 524 | struct arg_item *item; |
| 525 | struct conf_info *conf; |
| 526 | char *name = NULL; |
| 527 | enum trailer_info_type type; |
| 528 | |
| 529 | if (!skip_prefix(conf_key, "trailer.", &trailer_item)) |
| 530 | return 0; |
| 531 | |
| 532 | variable_name = strrchr(trailer_item, '.'); |
| 533 | if (!variable_name) |
| 534 | return 0; |
| 535 | |
| 536 | variable_name++; |
| 537 | for (size_t i = 0; i < ARRAY_SIZE(trailer_config_items); i++) { |
| 538 | if (strcmp(trailer_config_items[i].name, variable_name)) |
| 539 | continue; |
| 540 | name = xstrndup(trailer_item, variable_name - trailer_item - 1); |
| 541 | type = trailer_config_items[i].type; |
| 542 | break; |
| 543 | } |
| 544 | |
| 545 | if (!name) |
| 546 | return 0; |
| 547 | |
| 548 | item = get_conf_item(name); |
| 549 | conf = &item->conf; |
| 550 | free(name); |
| 551 | |
| 552 | switch (type) { |
| 553 | case TRAILER_KEY: |
| 554 | if (conf->key) |
| 555 | warning(_("more than one %s"), conf_key); |
| 556 | if (!value) |
| 557 | return config_error_nonbool(conf_key); |
| 558 | conf->key = xstrdup(value); |
| 559 | break; |
| 560 | case TRAILER_COMMAND: |
| 561 | if (conf->command) |
| 562 | warning(_("more than one %s"), conf_key); |
| 563 | if (!value) |
| 564 | return config_error_nonbool(conf_key); |
| 565 | conf->command = xstrdup(value); |
| 566 | break; |
| 567 | case TRAILER_CMD: |
| 568 | if (conf->cmd) |
| 569 | warning(_("more than one %s"), conf_key); |
| 570 | if (!value) |
| 571 | return config_error_nonbool(conf_key); |
| 572 | conf->cmd = xstrdup(value); |
| 573 | break; |
| 574 | case TRAILER_WHERE: |
| 575 | if (trailer_set_where(&conf->where, value)) |
| 576 | warning(_("unknown value '%s' for key '%s'"), value, conf_key); |
nothing calls this directly
no test coverage detected