| 732 | } |
| 733 | |
| 734 | enum bisect_error bisect_checkout(const struct object_id *bisect_rev, |
| 735 | int no_checkout) |
| 736 | { |
| 737 | struct commit *commit; |
| 738 | struct pretty_print_context pp = {0}; |
| 739 | struct strbuf commit_msg = STRBUF_INIT; |
| 740 | |
| 741 | refs_update_ref(get_main_ref_store(the_repository), NULL, |
| 742 | "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, |
| 743 | UPDATE_REFS_DIE_ON_ERR); |
| 744 | |
| 745 | if (no_checkout) { |
| 746 | refs_update_ref(get_main_ref_store(the_repository), NULL, |
| 747 | "BISECT_HEAD", bisect_rev, NULL, 0, |
| 748 | UPDATE_REFS_DIE_ON_ERR); |
| 749 | } else { |
| 750 | struct child_process cmd = CHILD_PROCESS_INIT; |
| 751 | |
| 752 | cmd.git_cmd = 1; |
| 753 | strvec_pushl(&cmd.args, "checkout", "-q", |
| 754 | oid_to_hex(bisect_rev), "--", NULL); |
| 755 | if (run_command(&cmd)) |
| 756 | /* |
| 757 | * Errors in `run_command()` itself, signaled by res < 0, |
| 758 | * and errors in the child process, signaled by res > 0 |
| 759 | * can both be treated as regular BISECT_FAILED (-1). |
| 760 | */ |
| 761 | return BISECT_FAILED; |
| 762 | } |
| 763 | |
| 764 | commit = lookup_commit_reference(the_repository, bisect_rev); |
| 765 | repo_format_commit_message(the_repository, commit, "[%H] %s%n", |
| 766 | &commit_msg, &pp); |
| 767 | fputs(commit_msg.buf, stdout); |
| 768 | strbuf_release(&commit_msg); |
| 769 | |
| 770 | return BISECT_OK; |
| 771 | } |
| 772 | |
| 773 | static struct commit *get_commit_reference(struct repository *r, |
| 774 | const struct object_id *oid) |
no test coverage detected