Skip to content

Commit 28271d1

Browse files
committed
sequencer (rebase -i): show the progress
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 78da129 commit 28271d1

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

sequencer.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,9 +1112,10 @@ struct todo_list {
11121112
struct strbuf buf;
11131113
struct todo_item *items;
11141114
int nr, alloc, current;
1115+
int done_nr, total_nr;
11151116
};
11161117

1117-
#define TODO_LIST_INIT { STRBUF_INIT, NULL, 0, 0, 0 }
1118+
#define TODO_LIST_INIT { STRBUF_INIT, NULL, 0, 0, 0, -1, -1 }
11181119

11191120
static void todo_list_release(struct todo_list *todo_list)
11201121
{
@@ -1222,6 +1223,17 @@ static int parse_insn_buffer(char *buf, struct todo_list *todo_list,
12221223
return 0;
12231224
}
12241225

1226+
static int count_commands(struct todo_list *todo_list)
1227+
{
1228+
int count = 0, i;
1229+
1230+
for (i = 0; i < todo_list->nr; i++)
1231+
if (todo_list->items[i].command != TODO_COMMENT)
1232+
count++;
1233+
1234+
return count;
1235+
}
1236+
12251237
static int read_populate_todo(struct todo_list *todo_list,
12261238
struct replay_opts *opts)
12271239
{
@@ -1242,6 +1254,23 @@ static int read_populate_todo(struct todo_list *todo_list,
12421254
res = parse_insn_buffer(todo_list->buf.buf, todo_list, opts);
12431255
if (res)
12441256
return error(_("Unusable instruction sheet: %s"), todo_file);
1257+
1258+
if (IS_REBASE_I()) {
1259+
struct todo_list done = TODO_LIST_INIT;
1260+
1261+
if (strbuf_read_file(&done.buf,
1262+
git_path_rebase_done(), 0) > 0 &&
1263+
!parse_insn_buffer(done.buf.buf, &done, opts))
1264+
todo_list->done_nr = count_commands(&done);
1265+
else
1266+
todo_list->done_nr = 0;
1267+
1268+
todo_list->total_nr = todo_list->done_nr
1269+
+ count_commands(todo_list);
1270+
1271+
todo_list_release(&done);
1272+
}
1273+
12451274
return 0;
12461275
}
12471276

@@ -1677,6 +1706,11 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
16771706
if (save_todo(todo_list, opts))
16781707
return -1;
16791708
if (IS_REBASE_I()) {
1709+
if (item->command != TODO_COMMENT)
1710+
fprintf(stderr, "Rebasing (%d/%d)%s",
1711+
++(todo_list->done_nr),
1712+
todo_list->total_nr,
1713+
file_exists(git_path_rebase_verbose()) ? "\n" : "\r");
16801714
unlink(git_path_rebase_msg());
16811715
unlink(author_script());
16821716
unlink(stopped_sha());

0 commit comments

Comments
 (0)