Skip to content

Commit 3f34f2d

Browse files
agrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3406554 commit 3f34f2d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

sequencer.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,16 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
23422342
sequencer_remove_state(&opts);
23432343
}
23442344

2345+
static void todo_list_write_total_nr(struct todo_list *todo_list)
2346+
{
2347+
FILE *f = fopen_or_warn(rebase_path_msgtotal(), "w");
2348+
2349+
if (f) {
2350+
fprintf(f, "%d\n", todo_list->total_nr);
2351+
fclose(f);
2352+
}
2353+
}
2354+
23452355
static int read_populate_todo(struct repository *r,
23462356
struct todo_list *todo_list,
23472357
struct replay_opts *opts)
@@ -2387,7 +2397,6 @@ static int read_populate_todo(struct repository *r,
23872397

23882398
if (is_rebase_i(opts)) {
23892399
struct todo_list done = TODO_LIST_INIT;
2390-
FILE *f = fopen_or_warn(rebase_path_msgtotal(), "w");
23912400

23922401
if (strbuf_read_file(&done.buf, rebase_path_done(), 0) > 0 &&
23932402
!todo_list_parse_insn_buffer(r, done.buf.buf, &done))
@@ -2399,10 +2408,7 @@ static int read_populate_todo(struct repository *r,
23992408
+ count_commands(todo_list);
24002409
todo_list_release(&done);
24012410

2402-
if (f) {
2403-
fprintf(f, "%d\n", todo_list->total_nr);
2404-
fclose(f);
2405-
}
2411+
todo_list_write_total_nr(todo_list);
24062412
}
24072413

24082414
return 0;

0 commit comments

Comments
 (0)