Skip to content

Commit 1451d0f

Browse files
agrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a930eb0 commit 1451d0f

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

sequencer.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4746,6 +4746,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
47464746
struct todo_list new_todo = TODO_LIST_INIT;
47474747
struct strbuf *buf = &todo_list->buf;
47484748
struct object_id oid;
4749+
int res;
47494750

47504751
get_oid(onto, &oid);
47514752
shortonto = find_unique_abbrev(&oid, DEFAULT_ABBREV);
@@ -4770,24 +4771,16 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
47704771
return error(_("nothing to do"));
47714772
}
47724773

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) {
47834779
apply_autostash(opts);
47844780
sequencer_remove_state(opts);
47854781

47864782
return -1;
4787-
}
4788-
4789-
strbuf_stripspace(&new_todo.buf, 1);
4790-
if (new_todo.buf.len == 0) {
4783+
} else if (res == -3) {
47914784
apply_autostash(opts);
47924785
sequencer_remove_state(opts);
47934786
todo_list_release(&new_todo);

0 commit comments

Comments
 (0)