[RFC,3/9] sequencer: update `total_nr' when adding an item to a todo list
diff mbox series

Message ID 20190717143918.7406-4-alban.gruin@gmail.com
State New
Headers show
Series
  • rebase -i: extend rebase.missingCommitsCheck to `--edit-todo' and co.
Related show

Commit Message

Alban Gruin July 17, 2019, 2:39 p.m. UTC
`total_nr' is the total amount of items, done and toto, that are in a
todo list.  But unlike `nr', it was not updated when an item was
appended to the list.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
---
 sequencer.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Junio C Hamano July 18, 2019, 7:52 p.m. UTC | #1
Alban Gruin <alban.gruin@gmail.com> writes:

> `total_nr' is the total amount of items, done and toto, that are in a

"amount" -> "number" perhaps.  Also s/toto/todo/ perhaps but I am
not sure what you wanted to say here, so...

> todo list.  But unlike `nr', it was not updated when an item was
> appended to the list.

Good finding.

>
> 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 cf262701e8..e61ae75451 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -2070,6 +2070,7 @@ 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;

When we do not use the value in an expression, we prefer post
increment, not pre increment.

>  	return todo_list->items + todo_list->nr++;
>  }
Alban Gruin July 19, 2019, 6:12 p.m. UTC | #2
Hi,

Le 18/07/2019 à 21:52, Junio C Hamano a écrit :
> Alban Gruin <alban.gruin@gmail.com> writes:
> > `total_nr' is the total amount of items, done and toto, that are in a
> 
> "amount" -> "number" perhaps.  Also s/toto/todo/ perhaps but I am
> not sure what you wanted to say here, so...
> 

`total_nr' is the number of commands, whether they have been executed or not.  
It’s used to show the progression of the rebase.

> > todo list.  But unlike `nr', it was not updated when an item was
> > appended to the list.
> 
> Good finding.
> 
> > 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 cf262701e8..e61ae75451 100644
> > --- a/sequencer.c
> > +++ b/sequencer.c
> > @@ -2070,6 +2070,7 @@ 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;
> 
> When we do not use the value in an expression, we prefer post
> increment, not pre increment.
> 
> >  	return todo_list->items + todo_list->nr++;
> >  
> >  }

Patch
diff mbox series

diff --git a/sequencer.c b/sequencer.c
index cf262701e8..e61ae75451 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2070,6 +2070,7 @@  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++;
 }