Skip to content

Commit 3adab6f

Browse files
committed
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 <[email protected]>
1 parent b5c9f1c commit 3adab6f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

builtin/merge.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static const char * const builtin_merge_usage[] = {
4848

4949
static int show_diffstat = 1, shortlog_len = -1, squash;
5050
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;
5252
static int allow_trivial = 1, have_message;
5353
static int overwrite_ignore = 1;
5454
static struct strbuf merge_msg = STRBUF_INIT;
@@ -193,7 +193,7 @@ static struct option builtin_merge_options[] = {
193193
"create a single commit instead of doing a merge"),
194194
OPT_BOOLEAN(0, "commit", &option_commit,
195195
"perform a commit if the merge succeeds (default)"),
196-
OPT_BOOLEAN('e', "edit", &option_edit,
196+
OPT_BOOL('e', "edit", &option_edit,
197197
"edit message before committing"),
198198
OPT_BOOLEAN(0, "ff", &allow_fast_forward,
199199
"allow fast-forward (default)"),
@@ -1287,11 +1287,15 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
12871287
merge_remote_util(commit) &&
12881288
merge_remote_util(commit)->obj &&
12891289
merge_remote_util(commit)->obj->type == OBJ_TAG) {
1290-
option_edit = 1;
1290+
if (option_edit < 0)
1291+
option_edit = 1;
12911292
allow_fast_forward = 0;
12921293
}
12931294
}
12941295

1296+
if (option_edit < 0)
1297+
option_edit = 0;
1298+
12951299
if (!use_strategies) {
12961300
if (!remoteheads->next)
12971301
add_strategies(pull_twohead, DEFAULT_TWOHEAD);

t/t7600-merge.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,4 +683,16 @@ test_expect_success GPG 'merge --ff-only tag' '
683683
test_cmp actual expect
684684
'
685685

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+
686698
test_done

0 commit comments

Comments
 (0)