diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-05-19 23:35:56 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-05-19 23:35:57 +0300 |
commit | cacc15ee3fa1a00b1a01ca2caf050cf2f6e0cc8f (patch) | |
tree | 268c9b0c2e956fb4b7095d45f9b49f0a5e154ba5 /sequencer.c | |
parent | dc3fd2486f4576a61570917c2ea6e165d380382d (diff) | |
parent | 170eea9750e1bca7a35b5d27def9ee77df92fdf1 (diff) |
Merge branch 'js/rebase-count-fixes'
A few bugs in the sequencer machinery that results in miscounting
the steps have been corrected.
* js/rebase-count-fixes:
rebase -r: fix the total number shown in the progress
rebase --update-refs: fix loops
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sequencer.c b/sequencer.c index b553b49fbb..bceb6abcb6 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2477,7 +2477,6 @@ void todo_list_release(struct todo_list *todo_list) static struct todo_item *append_new_todo(struct todo_list *todo_list) { ALLOC_GROW(todo_list->items, todo_list->nr + 1, todo_list->alloc); - todo_list->total_nr++; return todo_list->items + todo_list->nr++; } @@ -2668,7 +2667,7 @@ int todo_list_parse_insn_buffer(struct repository *r, char *buf, char *p = buf, *next_p; int i, res = 0, fixup_okay = file_exists(rebase_path_done()); - todo_list->current = todo_list->nr = 0; + todo_list->current = todo_list->nr = todo_list->total_nr = 0; for (i = 1; *p; i++, p = next_p) { char *eol = strchrnul(p, '\n'); @@ -2689,6 +2688,9 @@ int todo_list_parse_insn_buffer(struct repository *r, char *buf, item->commit = NULL; } + if (item->command != TODO_COMMENT) + todo_list->total_nr++; + if (fixup_okay) ; /* do nothing */ else if (is_fixup(item->command)) @@ -4270,7 +4272,7 @@ void todo_list_filter_update_refs(struct repository *r, if (!is_null_oid(&rec->after)) continue; - for (j = 0; !found && j < todo_list->total_nr; j++) { + for (j = 0; !found && j < todo_list->nr; j++) { struct todo_item *item = &todo_list->items[j]; const char *arg = todo_list->buf.buf + item->arg_offset; @@ -4300,7 +4302,7 @@ void todo_list_filter_update_refs(struct repository *r, * For each todo_item, check if its ref is in the update_refs list. * If not, then add it as an un-updated ref. */ - for (i = 0; i < todo_list->total_nr; i++) { + for (i = 0; i < todo_list->nr; i++) { struct todo_item *item = &todo_list->items[i]; const char *arg = todo_list->buf.buf + item->arg_offset; int j, found = 0; @@ -6148,7 +6150,8 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla todo_list_to_strbuf(r, &new_todo, &buf2, -1, 0); strbuf_swap(&new_todo.buf, &buf2); strbuf_release(&buf2); - new_todo.total_nr -= new_todo.nr; + /* Nothing is done yet, and we're reparsing, so let's reset the count */ + new_todo.total_nr = 0; if (todo_list_parse_insn_buffer(r, new_todo.buf.buf, &new_todo) < 0) BUG("invalid todo list after expanding IDs:\n%s", new_todo.buf.buf); |