| 633 | } |
| 634 | |
| 635 | static void print_preparing_worktree_line(int detach, |
| 636 | const char *branch, |
| 637 | const char *new_branch, |
| 638 | int force_new_branch) |
| 639 | { |
| 640 | if (force_new_branch) { |
| 641 | struct commit *commit = lookup_commit_reference_by_name(new_branch); |
| 642 | if (!commit) |
| 643 | fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch); |
| 644 | else |
| 645 | fprintf_ln(stderr, _("Preparing worktree (resetting branch '%s'; was at %s)"), |
| 646 | new_branch, |
| 647 | repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV)); |
| 648 | } else if (new_branch) { |
| 649 | fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch); |
| 650 | } else { |
| 651 | struct strbuf s = STRBUF_INIT; |
| 652 | if (!detach && !check_branch_ref(&s, branch) && |
| 653 | refs_ref_exists(get_main_ref_store(the_repository), s.buf)) |
| 654 | fprintf_ln(stderr, _("Preparing worktree (checking out '%s')"), |
| 655 | branch); |
| 656 | else { |
| 657 | struct commit *commit = lookup_commit_reference_by_name(branch); |
| 658 | if (!commit) |
| 659 | BUG("unreachable: invalid reference: %s", branch); |
| 660 | fprintf_ln(stderr, _("Preparing worktree (detached HEAD %s)"), |
| 661 | repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV)); |
| 662 | } |
| 663 | strbuf_release(&s); |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | /** |
| 668 | * Callback to short circuit iteration over refs on the first reference |
no test coverage detected