@@ -2477,7 +2477,6 @@ void todo_list_release(struct todo_list *todo_list)
2477
2477
static struct todo_item * append_new_todo (struct todo_list * todo_list )
2478
2478
{
2479
2479
ALLOC_GROW (todo_list -> items , todo_list -> nr + 1 , todo_list -> alloc );
2480
- todo_list -> total_nr ++ ;
2481
2480
return todo_list -> items + todo_list -> nr ++ ;
2482
2481
}
2483
2482
@@ -2668,7 +2667,7 @@ int todo_list_parse_insn_buffer(struct repository *r, char *buf,
2668
2667
char * p = buf , * next_p ;
2669
2668
int i , res = 0 , fixup_okay = file_exists (rebase_path_done ());
2670
2669
2671
- todo_list -> current = todo_list -> nr = 0 ;
2670
+ todo_list -> current = todo_list -> nr = todo_list -> total_nr = 0 ;
2672
2671
2673
2672
for (i = 1 ; * p ; i ++ , p = next_p ) {
2674
2673
char * eol = strchrnul (p , '\n' );
@@ -2689,6 +2688,9 @@ int todo_list_parse_insn_buffer(struct repository *r, char *buf,
2689
2688
item -> commit = NULL ;
2690
2689
}
2691
2690
2691
+ if (item -> command != TODO_COMMENT )
2692
+ todo_list -> total_nr ++ ;
2693
+
2692
2694
if (fixup_okay )
2693
2695
; /* do nothing */
2694
2696
else if (is_fixup (item -> command ))
@@ -4270,7 +4272,7 @@ void todo_list_filter_update_refs(struct repository *r,
4270
4272
if (!is_null_oid (& rec -> after ))
4271
4273
continue ;
4272
4274
4273
- for (j = 0 ; !found && j < todo_list -> total_nr ; j ++ ) {
4275
+ for (j = 0 ; !found && j < todo_list -> nr ; j ++ ) {
4274
4276
struct todo_item * item = & todo_list -> items [j ];
4275
4277
const char * arg = todo_list -> buf .buf + item -> arg_offset ;
4276
4278
@@ -4300,7 +4302,7 @@ void todo_list_filter_update_refs(struct repository *r,
4300
4302
* For each todo_item, check if its ref is in the update_refs list.
4301
4303
* If not, then add it as an un-updated ref.
4302
4304
*/
4303
- for (i = 0 ; i < todo_list -> total_nr ; i ++ ) {
4305
+ for (i = 0 ; i < todo_list -> nr ; i ++ ) {
4304
4306
struct todo_item * item = & todo_list -> items [i ];
4305
4307
const char * arg = todo_list -> buf .buf + item -> arg_offset ;
4306
4308
int j , found = 0 ;
@@ -6148,7 +6150,8 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
6148
6150
todo_list_to_strbuf (r , & new_todo , & buf2 , -1 , 0 );
6149
6151
strbuf_swap (& new_todo .buf , & buf2 );
6150
6152
strbuf_release (& buf2 );
6151
- new_todo .total_nr -= new_todo .nr ;
6153
+ /* Nothing is done yet, and we're reparsing, so let's reset the count */
6154
+ new_todo .total_nr = 0 ;
6152
6155
if (todo_list_parse_insn_buffer (r , new_todo .buf .buf , & new_todo ) < 0 )
6153
6156
BUG ("invalid todo list after expanding IDs:\n%s" ,
6154
6157
new_todo .buf .buf );
0 commit comments