Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin <alban.gruin@gmail.com>2019-11-24 20:43:30 +0300
committerJunio C Hamano <gitster@pobox.com>2019-11-25 06:24:49 +0300
commit3f34f2d8a4da82ddda48a591cbb091f24a5f3e58 (patch)
treef888e2325fad1006b0050b569837f19135ddf880 /sequencer.c
parent34065541e3f99ce23ac431032daf9d72072e650b (diff)
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>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sequencer.c b/sequencer.c
index 42313f8de6..ec7ea8d9e5 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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;