| 1718 | } |
| 1719 | |
| 1720 | static int do_commit(struct repository *r, |
| 1721 | const char *msg_file, const char *author, |
| 1722 | const char *reflog_action, |
| 1723 | struct replay_opts *opts, unsigned int flags, |
| 1724 | struct object_id *oid) |
| 1725 | { |
| 1726 | int res = 1; |
| 1727 | |
| 1728 | if (!(flags & EDIT_MSG) && !(flags & VERIFY_MSG)) { |
| 1729 | struct object_id oid; |
| 1730 | struct strbuf sb = STRBUF_INIT; |
| 1731 | |
| 1732 | if (msg_file && strbuf_read_file(&sb, msg_file, 2048) < 0) |
| 1733 | return error_errno(_("unable to read commit message " |
| 1734 | "from '%s'"), |
| 1735 | msg_file); |
| 1736 | |
| 1737 | res = try_to_commit(r, msg_file ? &sb : NULL, |
| 1738 | author, reflog_action, opts, flags, &oid); |
| 1739 | strbuf_release(&sb); |
| 1740 | if (!res) { |
| 1741 | refs_delete_ref(get_main_ref_store(r), "", |
| 1742 | "CHERRY_PICK_HEAD", NULL, REF_NO_DEREF); |
| 1743 | unlink(git_path_merge_msg(r)); |
| 1744 | if (!is_rebase_i(opts)) |
| 1745 | print_commit_summary(r, NULL, &oid, |
| 1746 | SUMMARY_SHOW_AUTHOR_DATE); |
| 1747 | return res; |
| 1748 | } |
| 1749 | } |
| 1750 | if (res == 1) { |
| 1751 | if (is_rebase_i(opts) && oid) |
| 1752 | if (write_rebase_head(oid)) |
| 1753 | return -1; |
| 1754 | return run_git_commit(msg_file, reflog_action, opts, flags); |
| 1755 | } |
| 1756 | |
| 1757 | return res; |
| 1758 | } |
| 1759 | |
| 1760 | static int is_original_commit_empty(struct commit *commit) |
| 1761 | { |
no test coverage detected