| 294 | #define abbrev_branch(name) abbrev_ref((name), "refs/heads/") |
| 295 | |
| 296 | static int config_read_branches(const char *key, const char *value, |
| 297 | const struct config_context *ctx UNUSED, |
| 298 | void *data UNUSED) |
| 299 | { |
| 300 | const char *orig_key = key; |
| 301 | char *name; |
| 302 | struct string_list_item *item; |
| 303 | struct branch_info *info; |
| 304 | enum { REMOTE, MERGE, REBASE, PUSH_REMOTE } type; |
| 305 | size_t key_len; |
| 306 | |
| 307 | if (!starts_with(key, "branch.")) |
| 308 | return 0; |
| 309 | |
| 310 | key += strlen("branch."); |
| 311 | if (strip_suffix(key, ".remote", &key_len)) |
| 312 | type = REMOTE; |
| 313 | else if (strip_suffix(key, ".merge", &key_len)) |
| 314 | type = MERGE; |
| 315 | else if (strip_suffix(key, ".rebase", &key_len)) |
| 316 | type = REBASE; |
| 317 | else if (strip_suffix(key, ".pushremote", &key_len)) |
| 318 | type = PUSH_REMOTE; |
| 319 | else |
| 320 | return 0; |
| 321 | |
| 322 | name = xmemdupz(key, key_len); |
| 323 | item = string_list_insert(&branch_list, name); |
| 324 | |
| 325 | if (!item->util) |
| 326 | item->util = xcalloc(1, sizeof(struct branch_info)); |
| 327 | info = item->util; |
| 328 | switch (type) { |
| 329 | case REMOTE: |
| 330 | if (info->remote_name) |
| 331 | warning(_("more than one %s"), orig_key); |
| 332 | info->remote_name = xstrdup(value); |
| 333 | break; |
| 334 | case MERGE: { |
| 335 | const char *space = strchr(value, ' '); |
| 336 | value = abbrev_branch(value); |
| 337 | while (space) { |
| 338 | char *merge; |
| 339 | merge = xstrndup(value, space - value); |
| 340 | string_list_append(&info->merge, merge); |
| 341 | value = abbrev_branch(space + 1); |
| 342 | space = strchr(value, ' '); |
| 343 | } |
| 344 | string_list_append(&info->merge, xstrdup(value)); |
| 345 | break; |
| 346 | } |
| 347 | case REBASE: |
| 348 | /* |
| 349 | * Consider invalid values as false and check the |
| 350 | * truth value with >= REBASE_TRUE. |
| 351 | */ |
| 352 | info->rebase = rebase_parse_value(value); |
| 353 | if (info->rebase == REBASE_INVALID) |
nothing calls this directly
no test coverage detected