From: Junio C Hamano Date: Thu, 14 Sep 2023 18:17:00 +0000 (-0700) Subject: Merge branch 'pw/rebase-i-after-failure' X-Git-Tag: v2.43.0-rc0~90 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b995e78147d0ec6bf3af4a7c31e41535409102da;p=thirdparty%2Fgit.git Merge branch 'pw/rebase-i-after-failure' Various fixes to the behaviour of "rebase -i" when the command got interrupted by conflicting changes. * pw/rebase-i-after-failure: rebase -i: fix adding failed command to the todo list rebase --continue: refuse to commit after failed command rebase: fix rewritten list for failed pick sequencer: factor out part of pick_commits() sequencer: use rebase_path_message() rebase -i: remove patch file after conflict resolution rebase -i: move unlink() calls --- b995e78147d0ec6bf3af4a7c31e41535409102da diff --cc sequencer.c index 3c5fdd68f4,f014c60cc8..9021cb8178 --- a/sequencer.c +++ b/sequencer.c @@@ -4661,6 -4630,68 +4667,68 @@@ N_("Could not execute the todo command\ " git rebase --edit-todo\n" " git rebase --continue\n"); + static int pick_one_commit(struct repository *r, + struct todo_list *todo_list, + struct replay_opts *opts, + int *check_todo, int* reschedule) + { + int res; + struct todo_item *item = todo_list->items + todo_list->current; + const char *arg = todo_item_get_arg(todo_list, item); + if (is_rebase_i(opts)) + opts->reflog_message = reflog_message( + opts, command_to_string(item->command), NULL); + + res = do_pick_commit(r, item, opts, is_final_fixup(todo_list), + check_todo); + if (is_rebase_i(opts) && res < 0) { + /* Reschedule */ + *reschedule = 1; + return -1; + } + if (item->command == TODO_EDIT) { + struct commit *commit = item->commit; + if (!res) { + if (!opts->verbose) + term_clear_line(); + fprintf(stderr, _("Stopped at %s... %.*s\n"), - short_commit_name(commit), item->arg_len, arg); ++ short_commit_name(r, commit), item->arg_len, arg); + } + return error_with_patch(r, commit, + arg, item->arg_len, opts, res, !res); + } + if (is_rebase_i(opts) && !res) + record_in_rewritten(&item->commit->object.oid, + peek_command(todo_list, 1)); + if (res && is_fixup(item->command)) { + if (res == 1) + intend_to_amend(); + return error_failed_squash(r, item->commit, opts, + item->arg_len, arg); + } else if (res && is_rebase_i(opts) && item->commit) { + int to_amend = 0; + struct object_id oid; + + /* + * If we are rewording and have either + * fast-forwarded already, or are about to + * create a new root commit, we want to amend, + * otherwise we do not. + */ + if (item->command == TODO_REWORD && + !repo_get_oid(r, "HEAD", &oid) && + (oideq(&item->commit->object.oid, &oid) || + (opts->have_squash_onto && + oideq(&opts->squash_onto, &oid)))) + to_amend = 1; + + return res | error_with_patch(r, item->commit, + arg, item->arg_len, opts, + res, to_amend); + } + return res; + } + static int pick_commits(struct repository *r, struct todo_list *todo_list, struct replay_opts *opts)