* Given the repo and refspecs, sets fork_point to the point at which the * current branch forked from its remote-tracking branch. Returns 0 on success, * -1 on failure. */
| 644 | * -1 on failure. |
| 645 | */ |
| 646 | static int get_rebase_fork_point(struct object_id *fork_point, const char *repo, |
| 647 | const char *refspec) |
| 648 | { |
| 649 | int ret; |
| 650 | struct branch *curr_branch; |
| 651 | const char *remote_branch; |
| 652 | struct child_process cp = CHILD_PROCESS_INIT; |
| 653 | struct strbuf sb = STRBUF_INIT; |
| 654 | |
| 655 | curr_branch = branch_get("HEAD"); |
| 656 | if (!curr_branch) |
| 657 | return -1; |
| 658 | |
| 659 | if (refspec) |
| 660 | remote_branch = get_tracking_branch(repo, refspec); |
| 661 | else |
| 662 | remote_branch = get_upstream_branch(repo); |
| 663 | |
| 664 | if (!remote_branch) |
| 665 | return -1; |
| 666 | |
| 667 | strvec_pushl(&cp.args, "merge-base", "--fork-point", |
| 668 | remote_branch, curr_branch->name, NULL); |
| 669 | cp.no_stdin = 1; |
| 670 | cp.no_stderr = 1; |
| 671 | cp.git_cmd = 1; |
| 672 | |
| 673 | ret = capture_command(&cp, &sb, GIT_MAX_HEXSZ); |
| 674 | if (ret) |
| 675 | goto cleanup; |
| 676 | |
| 677 | ret = get_oid_hex(sb.buf, fork_point); |
| 678 | if (ret) |
| 679 | goto cleanup; |
| 680 | |
| 681 | cleanup: |
| 682 | strbuf_release(&sb); |
| 683 | return ret ? -1 : 0; |
| 684 | } |
| 685 | |
| 686 | /** |
| 687 | * Sets merge_base to the octopus merge base of curr_head, merge_head and |
no test coverage detected