| 2067 | } |
| 2068 | |
| 2069 | static void comment_char_callback(const char *key, const char *value, |
| 2070 | const struct config_context *ctx, void *data) |
| 2071 | { |
| 2072 | struct comment_char_config *config = data; |
| 2073 | const struct key_value_info *kvi = ctx->kvi; |
| 2074 | unsigned key_id; |
| 2075 | |
| 2076 | if (!strcmp(key, "core.commentchar")) |
| 2077 | key_id = 0; |
| 2078 | else if (!strcmp(key, "core.commentstring")) |
| 2079 | key_id = 1; |
| 2080 | else |
| 2081 | return; |
| 2082 | |
| 2083 | config->last_key_id = key_id; |
| 2084 | config->auto_set = value && !strcmp(value, "auto"); |
| 2085 | if (kvi->origin_type != CONFIG_ORIGIN_FILE) { |
| 2086 | return; |
| 2087 | } else if (get_comment_key_flags(config, kvi->filename, key_id)) { |
| 2088 | set_comment_key_flags(config, kvi->filename, key_id, |
| 2089 | KEY_SEEN_TWICE); |
| 2090 | } else { |
| 2091 | struct comment_char_config_item *item; |
| 2092 | |
| 2093 | ALLOC_GROW_BY(config->item, config->nr, 1, config->alloc); |
| 2094 | item = &config->item[config->nr - 1]; |
| 2095 | item->key_id = key_id; |
| 2096 | item->scope = kvi->scope; |
| 2097 | item->path = xstrdup(kvi->filename); |
| 2098 | set_comment_key_flags(config, kvi->filename, key_id, |
| 2099 | KEY_SEEN_ONCE); |
| 2100 | } |
| 2101 | config->auto_set_in_file = config->auto_set; |
| 2102 | } |
| 2103 | |
| 2104 | static void add_config_scope_arg(struct repository *repo, struct strbuf *buf, |
| 2105 | struct comment_char_config_item *item) |
no test coverage detected