Skip to content

Commit f26af3f

Browse files
trastgitster
authored andcommitted
merge: add instructions to the commit message when editing
Before f824628 (merge: use editor by default in interactive sessions, 2012-01-10), git-merge only started an editor if the user explicitly asked for it with --edit. Thus it seemed unlikely that the user would need extra guidance. After f824628 the _normal_ thing is to start an editor. Give at least an indication of why we are doing it. The sentence about justification is one of the few things about standard git that are not agnostic to the workflow that the user chose. However, f824628 was proposed by Linus specifically to discourage users from merging unrelated upstream progress into topic branches. So we may as well take another step in the same direction. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 828ea97 commit f26af3f

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)