Web lists-archives.com

[PATCH 13/15] 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@xxxxxxxxx>
---
 sequencer.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index bfcbe8239b..93b9b40f66 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4608,7 +4608,7 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 	struct todo_list new_todo = TODO_LIST_INIT;
 	struct strbuf *buf = &todo_list->buf;
 	struct object_id oid;
-	int command_count;
+	int command_count, res;
 
 	get_oid(onto, &oid);
 	shortonto = find_unique_abbrev(&oid, DEFAULT_ABBREV);
@@ -4633,27 +4633,16 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 		return error(_("nothing to do"));
 	}
 
-	todo_list_transform(todo_list, flags | TODO_LIST_SHORTEN_IDS);
-
-	append_todo_help(flags & TODO_LIST_KEEP_EMPTY, command_count,
-			 shortrevisions, shortonto, buf);
-
-	if (write_message(buf->buf, buf->len, todo_file, 0))
-		return error_errno(_("could not write '%s'"), todo_file);
-
-	if (copy_file(rebase_path_todo_backup(), todo_file, 0666))
-		return error(_("could not copy '%s' to '%s'."), todo_file,
-			     rebase_path_todo_backup());
-
-	if (launch_sequence_editor(todo_file, &new_todo.buf, NULL)) {
+	res = edit_todo_list(todo_list, &new_todo, flags,
+			     command_count, shortrevisions, shortonto);
+	if (res == -1)
+		return -1;
+	else if (res == -2) {
 		apply_autostash(opts);
 		sequencer_remove_state(opts);
 
 		return -1;
-	}
-
-	strbuf_stripspace(&new_todo.buf, 1);
-	if (new_todo.buf.len == 0) {
+	} else if (res == -3) {
 		apply_autostash(opts);
 		sequencer_remove_state(opts);
 		todo_list_release(&new_todo);
@@ -4668,8 +4657,6 @@ int complete_action(struct replay_opts *opts, unsigned flags,
 		return -1;
 	}
 
-	todo_list_transform(&new_todo, flags & ~(TODO_LIST_SHORTEN_IDS));
-
 	if (opts->allow_ff && skip_unnecessary_picks(&new_todo, &oid)) {
 		todo_list_release(&new_todo);
 		return error(_("could not skip unnecessary pick commands"));
-- 
2.19.1