Skip to content

Commit 873ce7c

Browse files
committed
Merge branch 'tr/merge-edit-guidance'
* tr/merge-edit-guidance: merge: add instructions to the commit message when editing
2 parents af6b37f + f26af3f commit 873ce7c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

builtin/merge.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,21 @@ static void abort_commit(const char *err_msg)
885885
exit(1);
886886
}
887887

888+
static const char merge_editor_comment[] =
889+
N_("Please enter a commit message to explain why this merge is necessary,\n"
890+
"especially if it merges an updated upstream into a topic branch.\n"
891+
"\n"
892+
"Lines starting with '#' will be ignored, and an empty message aborts\n"
893+
"the commit.\n");
894+
888895
static void prepare_to_commit(void)
889896
{
890897
struct strbuf msg = STRBUF_INIT;
898+
const char *comment = _(merge_editor_comment);
891899
strbuf_addbuf(&msg, &merge_msg);
892900
strbuf_addch(&msg, '\n');
901+
if (0 < option_edit)
902+
strbuf_add_lines(&msg, "# ", comment, strlen(comment));
893903
write_merge_msg(&msg);
894904
run_hook(get_index_file(), "prepare-commit-msg",
895905
git_path("MERGE_MSG"), "merge", NULL, NULL);

0 commit comments

Comments
 (0)