summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Thomas Rast <trast@student.ethz.ch>2012-01-30 21:25:30 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-01-31 12:04:38 -0800
commitf26af3fcbcbd27392b8c94b1e4eb6e671b2466ab (patch)
treed935aef25ff4e5fee78f373108da9ad396993b86
parentGit 1.7.9 (diff)
downloadtgif-f26af3fcbcbd27392b8c94b1e4eb6e671b2466ab.tar.xz
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>
-rw-r--r--builtin/merge.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 3a451727d0..41d835e3f7 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -885,11 +885,21 @@ static void abort_commit(const char *err_msg)
exit(1);
}
+static const char merge_editor_comment[] =
+N_("Please enter a commit message to explain why this merge is necessary,\n"
+ "especially if it merges an updated upstream into a topic branch.\n"
+ "\n"
+ "Lines starting with '#' will be ignored, and an empty message aborts\n"
+ "the commit.\n");
+
static void prepare_to_commit(void)
{
struct strbuf msg = STRBUF_INIT;
+ const char *comment = _(merge_editor_comment);
strbuf_addbuf(&msg, &merge_msg);
strbuf_addch(&msg, '\n');
+ if (0 < option_edit)
+ strbuf_add_lines(&msg, "# ", comment, strlen(comment));
write_merge_msg(&msg);
run_hook(get_index_file(), "prepare-commit-msg",
git_path("MERGE_MSG"), "merge", NULL, NULL);