* Given a key-value pair, update the state of the given bundle list. * Returns 0 if the key-value pair is understood. Returns -1 if the key * is not understood or the value is malformed. */
| 141 | * is not understood or the value is malformed. |
| 142 | */ |
| 143 | static int bundle_list_update(const char *key, const char *value, |
| 144 | struct bundle_list *list) |
| 145 | { |
| 146 | struct strbuf id = STRBUF_INIT; |
| 147 | struct remote_bundle_info lookup = REMOTE_BUNDLE_INFO_INIT; |
| 148 | struct remote_bundle_info *bundle; |
| 149 | const char *subsection, *subkey; |
| 150 | size_t subsection_len; |
| 151 | |
| 152 | if (parse_config_key(key, "bundle", &subsection, &subsection_len, &subkey)) |
| 153 | return -1; |
| 154 | |
| 155 | if (!subsection_len) { |
| 156 | if (!strcmp(subkey, "version")) { |
| 157 | int version; |
| 158 | if (!git_parse_int(value, &version)) |
| 159 | return -1; |
| 160 | if (version != 1) |
| 161 | return -1; |
| 162 | |
| 163 | list->version = version; |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | if (!strcmp(subkey, "mode")) { |
| 168 | if (!strcmp(value, "all")) |
| 169 | list->mode = BUNDLE_MODE_ALL; |
| 170 | else if (!strcmp(value, "any")) |
| 171 | list->mode = BUNDLE_MODE_ANY; |
| 172 | else |
| 173 | return -1; |
| 174 | return 0; |
| 175 | } |
| 176 | |
| 177 | if (!strcmp(subkey, "heuristic")) { |
| 178 | int i; |
| 179 | for (i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) { |
| 180 | if (heuristics[i].heuristic && |
| 181 | heuristics[i].name && |
| 182 | !strcmp(value, heuristics[i].name)) { |
| 183 | list->heuristic = heuristics[i].heuristic; |
| 184 | return 0; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /* Ignore unknown heuristics. */ |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | /* Ignore other unknown global keys. */ |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | strbuf_add(&id, subsection, subsection_len); |
| 197 | |
| 198 | /* |
| 199 | * Check for an existing bundle with this <id>, or create one |
| 200 | * if necessary. |
no test coverage detected