Skip to content

Commit 83df07d

Browse files
committed
sequencer (rebase -i): show the progress
The interactive rebase keeps the user informed about its progress. If the sequencer wants to do the grunt work of the interactive rebase, it also needs to show that progress. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 0548510 commit 83df07d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

sequencer.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,7 @@ struct todo_list {
12141214
struct strbuf buf;
12151215
struct todo_item *items;
12161216
int nr, alloc, current;
1217+
int done_nr, total_nr;
12171218
};
12181219

12191220
#define TODO_LIST_INIT { STRBUF_INIT }
@@ -1326,6 +1327,17 @@ static int parse_insn_buffer(char *buf, struct todo_list *todo_list)
13261327
return res;
13271328
}
13281329

1330+
static int count_commands(struct todo_list *todo_list)
1331+
{
1332+
int count = 0, i;
1333+
1334+
for (i = 0; i < todo_list->nr; i++)
1335+
if (todo_list->items[i].command != TODO_COMMENT)
1336+
count++;
1337+
1338+
return count;
1339+
}
1340+
13291341
static int read_populate_todo(struct todo_list *todo_list,
13301342
struct replay_opts *opts)
13311343
{
@@ -1368,6 +1380,21 @@ static int read_populate_todo(struct todo_list *todo_list,
13681380
return error(_("Cannot revert during a cherry-pick."));
13691381
}
13701382

1383+
if (is_rebase_i(opts)) {
1384+
struct todo_list done = TODO_LIST_INIT;
1385+
1386+
if (strbuf_read_file(&done.buf, rebase_path_done(), 0) > 0 &&
1387+
!parse_insn_buffer(done.buf.buf, &done))
1388+
todo_list->done_nr = count_commands(&done);
1389+
else
1390+
todo_list->done_nr = 0;
1391+
1392+
todo_list->total_nr = todo_list->done_nr
1393+
+ count_commands(todo_list);
1394+
1395+
todo_list_release(&done);
1396+
}
1397+
13711398
return 0;
13721399
}
13731400

@@ -1904,6 +1931,11 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
19041931
if (save_todo(todo_list, opts))
19051932
return -1;
19061933
if (is_rebase_i(opts)) {
1934+
if (item->command != TODO_COMMENT)
1935+
fprintf(stderr, "Rebasing (%d/%d)%s",
1936+
++(todo_list->done_nr),
1937+
todo_list->total_nr,
1938+
opts->verbose ? "\n" : "\r");
19071939
unlink(rebase_path_message());
19081940
unlink(rebase_path_author_script());
19091941
unlink(rebase_path_stopped_sha());

0 commit comments

Comments
 (0)