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 <the_jk@spawned.biz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Joel Klinghed committed
Aug 14, 2021 at 21:40 UTC
8ef6aad664715c16caf6e36a7f6b174a06574477
2 files changed
+11
-3
builtin/commit.c
+3
-2
@@ -1253,8 +1253,6 @@ static int parse_and_validate_options(int argc, const char *argv[],
1253
1254
if (logfile || have_option_m || use_message)
1255
use_editor = 0;
1256
- if (0 <= edit_flag)
1257
- use_editor = edit_flag;
1256
1257
/* Sanity check options */
1258
if (amend && !current_head)
@@ -1344,6 +1342,9 @@ static int parse_and_validate_options(int argc, const char *argv[],
1342
}
1343
}
1344
1345
+ if (0 <= edit_flag)
1346
+ use_editor = edit_flag;
1347
+
1348
cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor);
1349
1350
handle_untracked_files_arg(s);
t/t7500-commit-template-squash-signoff.sh
+8
-1
@@ -270,7 +270,7 @@ EOF
270
271
test_expect_success 'commit --fixup provides correct one-line commit message' '
272
commit_for_rebase_autosquash_setup &&
273
- git commit --fixup HEAD~1 &&
273
+ EDITOR="echo ignored >>" git commit --fixup HEAD~1 &&
274
commit_msg_is "fixup! target message subject line"
275
'
276
@@ -281,6 +281,13 @@ test_expect_success 'commit --fixup -m"something" -m"extra"' '
281
282
extra"
283
'
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
+
291
get_commit_msg () {
292
rev="$1" &&
293
git log -1 --pretty=format:"%B" "$rev"