* Derives the remote-tracking branch from the remote and refspec. * * FIXME: The current implementation assumes the default mapping of * refs/heads/ to refs/remotes/ / . */
| 607 | * refs/heads/<branch_name> to refs/remotes/<remote_name>/<branch_name>. |
| 608 | */ |
| 609 | static const char *get_tracking_branch(const char *remote, const char *refspec) |
| 610 | { |
| 611 | struct refspec_item spec; |
| 612 | const char *spec_src; |
| 613 | const char *merge_branch; |
| 614 | |
| 615 | if (!refspec_item_init_fetch(&spec, refspec)) |
| 616 | die(_("invalid refspec '%s'"), refspec); |
| 617 | spec_src = spec.src; |
| 618 | if (!*spec_src || !strcmp(spec_src, "HEAD")) |
| 619 | spec_src = "HEAD"; |
| 620 | else if (skip_prefix(spec_src, "heads/", &spec_src)) |
| 621 | ; |
| 622 | else if (skip_prefix(spec_src, "refs/heads/", &spec_src)) |
| 623 | ; |
| 624 | else if (starts_with(spec_src, "refs/") || |
| 625 | starts_with(spec_src, "tags/") || |
| 626 | starts_with(spec_src, "remotes/")) |
| 627 | spec_src = ""; |
| 628 | |
| 629 | if (*spec_src) { |
| 630 | if (!strcmp(remote, ".")) |
| 631 | merge_branch = mkpath("refs/heads/%s", spec_src); |
| 632 | else |
| 633 | merge_branch = mkpath("refs/remotes/%s/%s", remote, spec_src); |
| 634 | } else |
| 635 | merge_branch = NULL; |
| 636 | |
| 637 | refspec_item_clear(&spec); |
| 638 | return merge_branch; |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * Given the repo and refspecs, sets fork_point to the point at which the |
no test coverage detected