Skip to content

Commit 36529f9

Browse files
committed
sequencer (rebase -i): allow fast-forwarding for edit/reword
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent f69a8be commit 36529f9

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

sequencer.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,9 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
856856
if (opts->allow_ff && !is_fixup(command) &&
857857
((parent && !hashcmp(parent->object.oid.hash, head)) ||
858858
(!parent && unborn)))
859-
return fast_forward_to(commit->object.oid.hash, head, unborn, opts);
859+
fast_forward = 1;
860860

861-
if (parent && parse_commit(parent) < 0)
861+
else if (parent && parse_commit(parent) < 0)
862862
/* TRANSLATORS: The first %s will be "revert" or
863863
"cherry-pick", the second %s a SHA1 */
864864
return error(_("%s: cannot parse parent commit %s"),
@@ -876,7 +876,9 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
876876
* reverse of it if we are revert.
877877
*/
878878

879-
if (command == TODO_REVERT) {
879+
if (fast_forward)
880+
; /* do nothing */
881+
else if (command == TODO_REVERT) {
880882
base = commit;
881883
base_label = msg.label;
882884
next = parent;
@@ -944,7 +946,10 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
944946
if (IS_REBASE_I())
945947
write_author_script(msg.message);
946948

947-
if (!opts->strategy || !strcmp(opts->strategy, "recursive") || command == TODO_REVERT) {
949+
if (fast_forward)
950+
res |= fast_forward_to(commit->object.oid.hash, head, unborn,
951+
opts);
952+
else if (!opts->strategy || !strcmp(opts->strategy, "recursive") || command == TODO_REVERT) {
948953
res |= do_recursive_merge(base, next, base_label, next_label,
949954
head, &msgbuf, opts);
950955
res |= write_message(&msgbuf, git_path_merge_msg());
@@ -968,14 +973,14 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
968973
* However, if the merge did not even start, then we don't want to
969974
* write it at all.
970975
*/
971-
if (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1))
976+
if (!fast_forward && command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1))
972977
update_ref(NULL, "CHERRY_PICK_HEAD", commit->object.oid.hash, NULL,
973978
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
974-
if (command == TODO_REVERT && ((opts->no_commit && res == 0) || res == 1))
979+
if (!fast_forward && command == TODO_REVERT && ((opts->no_commit && res == 0) || res == 1))
975980
update_ref(NULL, "REVERT_HEAD", commit->object.oid.hash, NULL,
976981
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
977982

978-
if (res) {
983+
if (!fast_forward && res) {
979984
error(command == TODO_REVERT
980985
? _("could not revert %s... %s")
981986
: _("could not apply %s... %s"),
@@ -985,12 +990,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
985990
goto leave;
986991
}
987992

988-
allow = allow_empty(opts, commit);
989-
if (allow < 0) {
993+
if (!fast_forward && (allow = allow_empty(opts, commit)) < 0) {
990994
res |= allow;
991995
goto leave;
992996
}
993-
if (!opts->no_commit)
997+
if (!opts->no_commit && (!fast_forward || edit || amend))
994998
res |= sequencer_commit(msg_file, opts, allow, edit, amend);
995999

9961000
if (!res && final_fixup) {

0 commit comments

Comments
 (0)