]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: directly call pick_commits() from complete_action()
authorAlban Gruin <alban.gruin@gmail.com>
Sun, 24 Nov 2019 17:43:32 +0000 (18:43 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Nov 2019 03:24:49 +0000 (12:24 +0900)
Currently, complete_action(), used by builtin/rebase.c to start a new
rebase, calls sequencer_continue() to do it.  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() in complete_action()
 - 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 in complete_action()
 - 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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c

index ec7ea8d9e5e86980c5b9b853f6543532a7d4f62c..ec0b793fc59218e7d2187a23cd1bf05622c9fa1b 100644 (file)
@@ -5140,15 +5140,21 @@ 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);
+       res = -1;
 
        if (checkout_onto(r, opts, onto_name, &oid, orig_head))
-               return -1;
+               goto cleanup;
 
        if (require_clean_work_tree(r, "rebase", "", 1, 1))
-               return -1;
+               goto cleanup;
 
-       return sequencer_continue(r, opts);
+       todo_list_write_total_nr(&new_todo);
+       res = pick_commits(r, &new_todo, opts);
+
+cleanup:
+       todo_list_release(&new_todo);
+
+       return res;
 }
 
 struct subject2item_entry {