sequencer: use edit_todo_list() in complete_action()

This changes complete_action() to use edit_todo_list(), now that it can handle the initial edit of the todo list. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alban Gruin committed Mar 5, 2019 at 20:18 UTC 1451d0f616fb1a046349cc8cd94736bcfde5e4a5
1 file changed +7 -14
sequencer.c
+7 -14
@@ -4746,6 +4746,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
4746 struct todo_list new_todo = TODO_LIST_INIT;
4747 struct strbuf *buf = &todo_list->buf;
4748 struct object_id oid;
4749 + int res;
4750
4751 get_oid(onto, &oid);
4752 shortonto = find_unique_abbrev(&oid, DEFAULT_ABBREV);
@@ -4770,24 +4771,16 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
4771 return error(_("nothing to do"));
4772 }
4773
4773 - if (todo_list_write_to_file(r, todo_list, todo_file,
4774 - shortrevisions, shortonto, -1,
4775 - flags | TODO_LIST_SHORTEN_IDS | TODO_LIST_APPEND_TODO_HELP))
4776 - return error_errno(_("could not write '%s'"), todo_file);
4777 -
4778 - if (copy_file(rebase_path_todo_backup(), todo_file, 0666))
4779 - return error(_("could not copy '%s' to '%s'."), todo_file,
4780 - rebase_path_todo_backup());
4781 -
4782 - if (launch_sequence_editor(todo_file, &new_todo.buf, NULL)) {
4774 + res = edit_todo_list(r, todo_list, &new_todo, shortrevisions,
4775 + shortonto, flags);
4776 + if (res == -1)
4777 + return -1;
4778 + else if (res == -2) {
4779 apply_autostash(opts);
4780 sequencer_remove_state(opts);
4781
4782 return -1;
4787 - }
4788 -
4789 - strbuf_stripspace(&new_todo.buf, 1);
4790 - if (new_todo.buf.len == 0) {
4783 + } else if (res == -3) {
4784 apply_autostash(opts);
4785 sequencer_remove_state(opts);
4786 todo_list_release(&new_todo);