| 921 | |
| 922 | static void write_merge_heads(struct commit_list *); |
| 923 | static void prepare_to_commit(struct commit_list *remoteheads) |
| 924 | { |
| 925 | struct strbuf msg = STRBUF_INIT; |
| 926 | const char *index_file = repo_get_index_file(the_repository); |
| 927 | |
| 928 | if (!no_verify) { |
| 929 | int invoked_hook; |
| 930 | |
| 931 | if (run_commit_hook(0 < option_edit, index_file, &invoked_hook, |
| 932 | "pre-merge-commit", NULL)) |
| 933 | abort_commit(remoteheads, NULL); |
| 934 | /* |
| 935 | * Re-read the index as pre-merge-commit hook could have updated it, |
| 936 | * and write it out as a tree. We must do this before we invoke |
| 937 | * the editor and after we invoke run_status above. |
| 938 | */ |
| 939 | if (invoked_hook) |
| 940 | discard_index(the_repository->index); |
| 941 | } |
| 942 | read_index_from(the_repository->index, index_file, |
| 943 | repo_get_git_dir(the_repository)); |
| 944 | strbuf_addbuf(&msg, &merge_msg); |
| 945 | if (squash) |
| 946 | BUG("the control must not reach here under --squash"); |
| 947 | if (0 < option_edit) { |
| 948 | strbuf_addch(&msg, '\n'); |
| 949 | if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) { |
| 950 | wt_status_append_cut_line(&msg); |
| 951 | strbuf_commented_addf(&msg, comment_line_str, "\n"); |
| 952 | } |
| 953 | strbuf_commented_addf(&msg, comment_line_str, |
| 954 | _(merge_editor_comment)); |
| 955 | if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) |
| 956 | strbuf_commented_addf(&msg, comment_line_str, |
| 957 | _(scissors_editor_comment)); |
| 958 | else |
| 959 | strbuf_commented_addf(&msg, comment_line_str, |
| 960 | _(no_scissors_editor_comment), comment_line_str); |
| 961 | } |
| 962 | if (signoff) |
| 963 | append_signoff(&msg, ignored_log_message_bytes(msg.buf, msg.len), 0); |
| 964 | write_merge_heads(remoteheads); |
| 965 | write_file_buf(git_path_merge_msg(the_repository), msg.buf, msg.len); |
| 966 | if (run_commit_hook(0 < option_edit, repo_get_index_file(the_repository), |
| 967 | NULL, "prepare-commit-msg", |
| 968 | git_path_merge_msg(the_repository), "merge", NULL)) |
| 969 | abort_commit(remoteheads, NULL); |
| 970 | if (0 < option_edit) { |
| 971 | if (launch_editor(git_path_merge_msg(the_repository), NULL, NULL)) |
| 972 | abort_commit(remoteheads, NULL); |
| 973 | } |
| 974 | |
| 975 | if (!no_verify && run_commit_hook(0 < option_edit, repo_get_index_file(the_repository), |
| 976 | NULL, "commit-msg", |
| 977 | git_path_merge_msg(the_repository), NULL)) |
| 978 | abort_commit(remoteheads, NULL); |
| 979 | |
| 980 | read_merge_msg(&msg); |
no test coverage detected