Skip to content

Commit 8ef6aad

Browse files
thejkgitster
authored andcommitted
commit: restore --edit when combined with --fixup
Recent changes to --fixup, adding amend suboption, caused the --edit flag to be ignored as use_editor was always set to zero. Restore edit_flag having higher priority than fixup_message when deciding the value of use_editor by moving the edit flag condition later in the method. Signed-off-by: Joel Klinghed <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d213e4 commit 8ef6aad

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

builtin/commit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,6 @@ static int parse_and_validate_options(int argc, const char *argv[],
12531253

12541254
if (logfile || have_option_m || use_message)
12551255
use_editor = 0;
1256-
if (0 <= edit_flag)
1257-
use_editor = edit_flag;
12581256

12591257
/* Sanity check options */
12601258
if (amend && !current_head)
@@ -1344,6 +1342,9 @@ static int parse_and_validate_options(int argc, const char *argv[],
13441342
}
13451343
}
13461344

1345+
if (0 <= edit_flag)
1346+
use_editor = edit_flag;
1347+
13471348
cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor);
13481349

13491350
handle_untracked_files_arg(s);

t/t7500-commit-template-squash-signoff.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ EOF
270270

271271
test_expect_success 'commit --fixup provides correct one-line commit message' '
272272
commit_for_rebase_autosquash_setup &&
273-
git commit --fixup HEAD~1 &&
273+
EDITOR="echo ignored >>" git commit --fixup HEAD~1 &&
274274
commit_msg_is "fixup! target message subject line"
275275
'
276276

@@ -281,6 +281,13 @@ test_expect_success 'commit --fixup -m"something" -m"extra"' '
281281
282282
extra"
283283
'
284+
test_expect_success 'commit --fixup --edit' '
285+
commit_for_rebase_autosquash_setup &&
286+
EDITOR="printf \"something\nextra\" >>" git commit --fixup HEAD~1 --edit &&
287+
commit_msg_is "fixup! target message subject linesomething
288+
extra"
289+
'
290+
284291
get_commit_msg () {
285292
rev="$1" &&
286293
git log -1 --pretty=format:"%B" "$rev"

0 commit comments

Comments
 (0)