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. Based on initiail analysis by Jonathan Nieder. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Feb 9, 2012 at 13:30 UTC 3adab6f3a7793253b22a4a7aae34221d19e0236a
2 files changed +19 -3
builtin/merge.c
+7 -3
@@ -48,7 +48,7 @@ static const char * const builtin_merge_usage[] = {
48
49 static int show_diffstat = 1, shortlog_len = -1, squash;
50 static int option_commit = 1, allow_fast_forward = 1;
51 -static int fast_forward_only, option_edit;
51 +static int fast_forward_only, option_edit = -1;
52 static int allow_trivial = 1, have_message;
53 static int overwrite_ignore = 1;
54 static struct strbuf merge_msg = STRBUF_INIT;
@@ -193,7 +193,7 @@ static struct option builtin_merge_options[] = {
193 "create a single commit instead of doing a merge"),
194 OPT_BOOLEAN(0, "commit", &option_commit,
195 "perform a commit if the merge succeeds (default)"),
196 - OPT_BOOLEAN('e', "edit", &option_edit,
196 + OPT_BOOL('e', "edit", &option_edit,
197 "edit message before committing"),
198 OPT_BOOLEAN(0, "ff", &allow_fast_forward,
199 "allow fast-forward (default)"),
@@ -1287,11 +1287,15 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1287 merge_remote_util(commit) &&
1288 merge_remote_util(commit)->obj &&
1289 merge_remote_util(commit)->obj->type == OBJ_TAG) {
1290 - option_edit = 1;
1290 + if (option_edit < 0)
1291 + option_edit = 1;
1292 allow_fast_forward = 0;
1293 }
1294 }
1295
1296 + if (option_edit < 0)
1297 + option_edit = 0;
1298 +
1299 if (!use_strategies) {
1300 if (!remoteheads->next)
1301 add_strategies(pull_twohead, DEFAULT_TWOHEAD);
t/t7600-merge.sh
+12
@@ -683,4 +683,16 @@ test_expect_success GPG 'merge --ff-only tag' '
683 test_cmp actual expect
684 '
685
686 +test_expect_success GPG 'merge --no-edit tag should skip editor' '
687 + git reset --hard c0 &&
688 + git commit --allow-empty -m "A newer commit" &&
689 + git tag -f -s -m "A newer commit" signed &&
690 + git reset --hard c0 &&
691 +
692 + EDITOR=false git merge --no-edit signed &&
693 + git rev-parse signed^0 >expect &&
694 + git rev-parse HEAD^2 >actual &&
695 + test_cmp actual expect
696 +'
697 +
698 test_done