summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/sequencer.c b/sequencer.c
index 1bee26ebd5..763ccbbc45 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2130,6 +2130,7 @@ void todo_list_release(struct todo_list *todo_list)
static struct todo_item *append_new_todo(struct todo_list *todo_list)
{
ALLOC_GROW(todo_list->items, todo_list->nr + 1, todo_list->alloc);
+ todo_list->total_nr++;
return todo_list->items + todo_list->nr++;
}
@@ -2401,6 +2402,16 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
sequencer_remove_state(&opts);
}
+static void todo_list_write_total_nr(struct todo_list *todo_list)
+{
+ FILE *f = fopen_or_warn(rebase_path_msgtotal(), "w");
+
+ if (f) {
+ fprintf(f, "%d\n", todo_list->total_nr);
+ fclose(f);
+ }
+}
+
static int read_populate_todo(struct repository *r,
struct todo_list *todo_list,
struct replay_opts *opts)
@@ -2446,7 +2457,6 @@ static int read_populate_todo(struct repository *r,
if (is_rebase_i(opts)) {
struct todo_list done = TODO_LIST_INIT;
- FILE *f = fopen_or_warn(rebase_path_msgtotal(), "w");
if (strbuf_read_file(&done.buf, rebase_path_done(), 0) > 0 &&
!todo_list_parse_insn_buffer(r, done.buf.buf, &done))
@@ -2458,10 +2468,7 @@ static int read_populate_todo(struct repository *r,
+ count_commands(todo_list);
todo_list_release(&done);
- if (f) {
- fprintf(f, "%d\n", todo_list->total_nr);
- fclose(f);
- }
+ todo_list_write_total_nr(todo_list);
}
return 0;
@@ -5176,6 +5183,7 @@ static int skip_unnecessary_picks(struct repository *r,
MOVE_ARRAY(todo_list->items, todo_list->items + i, todo_list->nr - i);
todo_list->nr -= i;
todo_list->current = 0;
+ todo_list->done_nr += i;
if (is_fixup(peek_command(todo_list, 0)))
record_in_rewritten(base_oid, peek_command(todo_list, 0));
@@ -5255,15 +5263,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 {