Merge branch 'ag/sequencer-todo-updates'

Reduce unnecessary reading of state variables back from the disk
during sequencer operation.

* ag/sequencer-todo-updates:
  sequencer: directly call pick_commits() from complete_action()
  rebase: fill `squash_onto' in get_replay_opts()
  sequencer: move the code writing total_nr on the disk to a new function
  sequencer: update `done_nr' when skipping commands in a todo list
  sequencer: update `total_nr' when adding an item to a todo list
This commit is contained in:
Junio C Hamano 2019-12-16 13:08:31 -08:00
Родитель 571fb96573 393adf7a6f
Коммит 37c2619d91
2 изменённых файлов: 29 добавлений и 9 удалений

Просмотреть файл

@ -130,6 +130,12 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
parse_strategy_opts(&replay, strategy_buf.buf);
strbuf_release(&strategy_buf);
if (opts->squash_onto) {
oidcpy(&replay.squash_onto, opts->squash_onto);
replay.have_squash_onto = 1;
}
return replay;
}

Просмотреть файл

@ -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 {