[v2,5/5] sequencer: directly call pick_commits() from complete_action()
diff mbox series

Message ID 20191007092641.12661-6-alban.gruin@gmail.com
State New
Headers show
  • Use complete_action's todo list to do the rebase
Related show

Commit Message

Alban Gruin Oct. 7, 2019, 9:26 a.m. UTC
Currently, complete_action() calls sequencer_continue() to do the
rebase.  Before the former calls pick_commits(), it

 - calls read_and_refresh_cache() -- this is unnecessary here as we've
   just called require_clean_work_tree()
 - calls read_populate_opts() -- this is unnecessary as we're starting a
   new rebase, so opts is fully populated
 - loads the todo list -- this is unnecessary as we've just populated
   the todo list
 - commits any staged changes -- this is unnecessary as we're starting a
   new rebase, so there are no staged changes
 - calls record_in_rewritten() -- this is unnecessary as we're starting
   a new rebase.

This changes complete_action() to directly call pick_commits() to avoid
these unnecessary steps.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Reworded commit.

sequencer.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff mbox series

diff --git a/sequencer.c b/sequencer.c
index ec7ea8d9e5..b395dd6e11 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -5140,15 +5140,17 @@  int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
 		return error_errno(_("could not write '%s'"), todo_file);
-	todo_list_release(&new_todo);
 	if (checkout_onto(r, opts, onto_name, &oid, orig_head))
 		return -1;
 	if (require_clean_work_tree(r, "rebase", "", 1, 1))
 		return -1;
-	return sequencer_continue(r, opts);
+	todo_list_write_total_nr(&new_todo);
+	res = pick_commits(r, &new_todo, opts);
+	todo_list_release(&new_todo);
+	return res;
 struct subject2item_entry {