MCPcopy Create free account
hub / github.com/git/git / print_preparing_worktree_line

Function print_preparing_worktree_line

builtin/worktree.c:635–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635static 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

Callers 1

addFunction · 0.85

Calls 7

fprintf_lnFunction · 0.85
repo_find_unique_abbrevFunction · 0.85
check_branch_refFunction · 0.85
refs_ref_existsFunction · 0.85
get_main_ref_storeFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected