1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-23 23:06:12 +02:00

sequencer: move the code writing total_nr on the disk to a new function

The total number of commands can be used to show the progression of the
rebasing in a shell.  It is written to the disk by read_populate_todo()
when the todo list is loaded from sequencer_continue() or
pick_commits(), but not by complete_action().

This moves the part writing total_nr to a new function so it can be
called from complete_action().

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Alban Gruin 2019-11-24 18:43:30 +01:00 committed by Junio C Hamano
parent 34065541e3
commit 3f34f2d8a4

View File

@ -2342,6 +2342,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)
@ -2387,7 +2397,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))
@ -2399,10 +2408,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;