git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git merge <tag>: Spawning an editor can't be disabled

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 9, 2012, 21:20 UTC
Message-ID
<7vpqdnvh3b.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120209160803.GA5742@burratino>
Jonathan Nieder <jrnieder@gmail.com> writes:
> Patch relies on "merge: use editor by default in interactive sessions"
> from master.  If this looks like a sane approach, I can resend with a
> proposed log message and a test for t/t7600-merge.sh.  (Or if someone
> else wants to do it first, even better.)

Please do not depend on that one that will never be merged to 1.7.9.x maintenance track.

Your approach is the right one, though. A patch for 1.7.9.1, on top of b5c9f1c (merge: do not create a signed tag merge under --ff-only option, 2012-02-05), would look like this, I think.

I think various "0 < option_edit" we can find in f824628 (merge: use editor by default in interactive sessions, 2012-01-10) and f26af3f (merge: add instructions to the commit message when editing, 2012-01-30) can and should be reverted back to just "option_edit", as nobody should be looking at option_edit before the "if edit is negative, set it to the default" we can see in the last hunk of this patch (except for the "merging tag? turn editing on by default unless --no-edit is given" that is the topic of this thread).

Thanks.
-- >8 --
Subject: merge: do not launch an editor on "--no-edit $tag"
When the user explicitly asked us not to, don't launch an editor.

But do everything else the same way as the "edit" case, i.e. leave the comment with verification result in the log template and record the mergesig in the resulting merge commit for later inspection.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/merge.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index b4fbc60..f385b8a 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -48,7 +48,7 @@ static const char * const builtin_merge_usage[] = {
 
 static int show_diffstat = 1, shortlog_len = -1, squash;
 static int option_commit = 1, allow_fast_forward = 1;
-static int fast_forward_only, option_edit;
+static int fast_forward_only, option_edit = -1;
 static int allow_trivial = 1, have_message;
 static int overwrite_ignore = 1;
 static struct strbuf merge_msg = STRBUF_INIT;
@@ -193,7 +193,7 @@ static struct option builtin_merge_options[] = {
 		"create a single commit instead of doing a merge"),
 	OPT_BOOLEAN(0, "commit", &option_commit,
 		"perform a commit if the merge succeeds (default)"),
-	OPT_BOOLEAN('e', "edit", &option_edit,
+	OPT_BOOL('e', "edit", &option_edit,
 		"edit message before committing"),
 	OPT_BOOLEAN(0, "ff", &allow_fast_forward,
 		"allow fast-forward (default)"),
@@ -1287,11 +1287,15 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		    merge_remote_util(commit) &&
 		    merge_remote_util(commit)->obj &&
 		    merge_remote_util(commit)->obj->type == OBJ_TAG) {
-			option_edit = 1;
+			if (option_edit < 0)
+				option_edit = 1;
 			allow_fast_forward = 0;
 		}
 	}
 
+	if (option_edit < 0)
+		option_edit = 0;
+
 	if (!use_strategies) {
 		if (!remoteheads->next)
 			add_strategies(pull_twohead, DEFAULT_TWOHEAD);
Previous: Jonathan NiederNext: Junio C Hamano
Message 6 of 7 in “Re: git merge <tag>: Spawning an editor can't be disabled”
  1. Jonathan NiederFeb 9, 2012
  2. Junio C HamanoFeb 9, 2012
  3. Johannes SixtFeb 9, 2012
  4. Junio C HamanoFeb 9, 2012
  5. Jonathan NiederFeb 9, 2012
  6. Junio C HamanoFeb 9, 2012
  7. Junio C HamanoFeb 9, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.