| 379 | } |
| 380 | |
| 381 | static void read_branches_file(struct repository *repo, struct remote *remote) |
| 382 | { |
| 383 | char *frag, *to_free = NULL; |
| 384 | struct strbuf buf = STRBUF_INIT; |
| 385 | FILE *f = fopen_or_warn(repo_git_path_append(repo, &buf, |
| 386 | "branches/%s", remote->name), "r"); |
| 387 | |
| 388 | if (!f) |
| 389 | goto out; |
| 390 | |
| 391 | warn_about_deprecated_remote_type("branches", remote); |
| 392 | |
| 393 | strbuf_getline_lf(&buf, f); |
| 394 | fclose(f); |
| 395 | strbuf_trim(&buf); |
| 396 | if (!buf.len) |
| 397 | goto out; |
| 398 | |
| 399 | remote->configured_in_repo = 1; |
| 400 | remote->origin = REMOTE_BRANCHES; |
| 401 | |
| 402 | /* |
| 403 | * The branches file would have URL and optionally |
| 404 | * #branch specified. The default (or specified) branch is |
| 405 | * fetched and stored in the local branch matching the |
| 406 | * remote name. |
| 407 | */ |
| 408 | frag = strchr(buf.buf, '#'); |
| 409 | if (frag) |
| 410 | *(frag++) = '\0'; |
| 411 | else |
| 412 | frag = to_free = repo_default_branch_name(repo, 0); |
| 413 | |
| 414 | add_url_alias(repo->remote_state, remote, buf.buf); |
| 415 | refspec_appendf(&remote->fetch, "refs/heads/%s:refs/heads/%s", |
| 416 | frag, remote->name); |
| 417 | |
| 418 | /* |
| 419 | * Cogito compatible push: push current HEAD to remote #branch |
| 420 | * (master if missing) |
| 421 | */ |
| 422 | refspec_appendf(&remote->push, "HEAD:refs/heads/%s", frag); |
| 423 | remote->fetch_tags = 1; /* always auto-follow */ |
| 424 | |
| 425 | out: |
| 426 | strbuf_release(&buf); |
| 427 | free(to_free); |
| 428 | } |
| 429 | #endif /* WITH_BREAKING_CHANGES */ |
| 430 | |
| 431 | static int handle_config(const char *key, const char *value, |
no test coverage detected