| 677 | } |
| 678 | |
| 679 | static int parse_config_env_list(char *env, struct key_value_info *kvi, |
| 680 | config_fn_t fn, void *data) |
| 681 | { |
| 682 | char *cur = env; |
| 683 | while (cur && *cur) { |
| 684 | const char *key = sq_dequote_step(cur, &cur); |
| 685 | if (!key) |
| 686 | return error(_("bogus format in %s"), |
| 687 | CONFIG_DATA_ENVIRONMENT); |
| 688 | |
| 689 | if (!cur || isspace(*cur)) { |
| 690 | /* old-style 'key=value' */ |
| 691 | if (git_config_parse_parameter(key, fn, data) < 0) |
| 692 | return -1; |
| 693 | } |
| 694 | else if (*cur == '=') { |
| 695 | /* new-style 'key'='value' */ |
| 696 | const char *value; |
| 697 | |
| 698 | cur++; |
| 699 | if (*cur == '\'') { |
| 700 | /* quoted value */ |
| 701 | value = sq_dequote_step(cur, &cur); |
| 702 | if (!value || (cur && !isspace(*cur))) { |
| 703 | return error(_("bogus format in %s"), |
| 704 | CONFIG_DATA_ENVIRONMENT); |
| 705 | } |
| 706 | } else if (!*cur || isspace(*cur)) { |
| 707 | /* implicit bool: 'key'= */ |
| 708 | value = NULL; |
| 709 | } else { |
| 710 | return error(_("bogus format in %s"), |
| 711 | CONFIG_DATA_ENVIRONMENT); |
| 712 | } |
| 713 | |
| 714 | if (config_parse_pair(key, value, kvi, fn, data) < 0) |
| 715 | return -1; |
| 716 | } |
| 717 | else { |
| 718 | /* unknown format */ |
| 719 | return error(_("bogus format in %s"), |
| 720 | CONFIG_DATA_ENVIRONMENT); |
| 721 | } |
| 722 | |
| 723 | if (cur) { |
| 724 | while (isspace(*cur)) |
| 725 | cur++; |
| 726 | } |
| 727 | } |
| 728 | return 0; |
| 729 | } |
| 730 | |
| 731 | int git_config_from_parameters(config_fn_t fn, void *data) |
| 732 | { |
no test coverage detected