git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: Junio C Hamano <gitster@pobox.com>
Cc: <git@vger.kernel.org>
Subject: [PATCH] merge: add instructions to the commit message when editing
Date: Mon, 30 Jan 2012 21:25:30 +0100	[thread overview]
Message-ID: <0c9a880c7dca27520f957446c6b0e72e93609b03.1327954927.git.trast@student.ethz.ch> (raw)
In-Reply-To: <7vd3a1caxb.fsf@alter.siamese.dyndns.org>

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>
---
 builtin/merge.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index bfb7547..ed628b8 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -885,11 +885,22 @@ static void abort_commit(const char *err_msg)
 	exit(1);
 }
 
+static const char merge_editor_comment[] =
+N_("Please enter the commit message for your merge commit.  You should\n"
+"justify it especially if it merges an updated upstream into a topic\n"
+"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);
-- 
1.7.9.350.ga960f

  reply	other threads:[~2012-01-30 20:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-23 22:18 [PATCH] merge: use editor by default in interactive sessions Junio C Hamano
2012-01-23 22:27 ` Michael Haggerty
2012-01-23 22:34   ` Junio C Hamano
2012-01-30 17:06 ` Thomas Rast
2012-01-30 18:17   ` Junio C Hamano
2012-01-30 20:25     ` Thomas Rast [this message]
2012-01-30 21:03       ` [PATCH] merge: add instructions to the commit message when editing Junio C Hamano
2012-01-30 21:43         ` Thomas Rast
2012-01-30 21:52           ` Junio C Hamano
2012-01-31  7:46             ` Thomas Rast
2012-02-23 12:43 ` [PATCH] merge: use editor by default in interactive sessions Erik Faye-Lund
2012-02-23 19:23   ` Junio C Hamano
2012-02-23 20:26     ` Junio C Hamano
2012-02-23 20:31       ` Erik Faye-Lund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c9a880c7dca27520f957446c6b0e72e93609b03.1327954927.git.trast@student.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).