Re: [RFC PATCH 4/9] sequencer: update `done_nr' when skipping commands in a todo list
- From
Alban Gruin <alban.gruin@gmail.com>
- Date
- Jul 19, 2019, 18:13 UTC
- Message-ID
- <1732521.CJWHkCQAay@andromeda>
- In-Reply-To
- <xmqqo91rxgm7.fsf@gitster-ct.c.googlers.com>
Hi,
Le 18/07/2019 à 21:55, Junio C Hamano a écrit :
Show 12 quoted lines
> Alban Gruin <alban.gruin@gmail.com> writes:
> > In a todo list, `done_nr' is the amount of commands that were executed
> > or skipped, but skip_unnecessary_picks() did not update it.
>
> OK. Together with 3/9 and this one, any increment of total_nr and
> done_nr in the existing code is not removed; does it mean that
> nobody actually cares what these fields contain? IOW, there is no
> code that says "if (list->total_nr <= i) { we are done; }" etc.?
>
> Or are these fields used later, but somehow the lack of increment in
> the places touched by 3/9 and 4/9 is compensated?
> `total_nr' is not used for this, because it’s not necessarily the number of items in the todo list. That’s the role of `nr'. So the comparison is more like "if (list->nr <= i) { we are done; }".
Same think for `done_nr'. Each time a command is executed, git prints "Rebasing ($done_nr/$total_nr)". These two variables are written to the disk, and might be used by a shell prompt (eg. git-prompt.sh, oh my zsh…)
And this is actually how I found this. Originally, I wrote what became 5/9 and 6/9, without touching to `done_nr' and `total_nr'. All rebase tests (t34??*) passed, but t9903.15 ("prompt - rebase merge") failed, because the value was incorrect.
The reason is that, before I changed sequencer_continue() in 6/9, it called another function, read_populate_todo(), which would recompute `done_nr' and `total_nr', then write them to the disk. With my changes, these values would not have been updated after adding `exec' commands or skipping picks in complete_action(), so the numbers written to the disk were incorrect.
tl;dr: it does not impact how the rebase works, but it might impact the messages printed while rebasing or shell prompts.
Show 13 quoted lines
> > Signed-off-by: Alban Gruin <alban.gruin@gmail.com> > > --- > > > > sequencer.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/sequencer.c b/sequencer.c > > index e61ae75451..ec9c3d4dc5 100644 > > --- a/sequencer.c > > +++ b/sequencer.c > > @@ -4939,6 +4939,7 @@ static int skip_unnecessary_picks(struct repository > > *r,> > > MOVE_ARRAY(todo_list->items, todo_list->items + i,
todo_list->nr - i);
Show 8 quoted lines
> > todo_list->nr -= i; > > todo_list->current = 0; > > > > + todo_list->done_nr += i; > > > > if (is_fixup(peek_command(todo_list, 0))) > > > > record_in_rewritten(base_oid,
peek_command(todo_list, 0));