@@ -2477,7 +2477,6 @@ void todo_list_release(struct todo_list *todo_list)
24772477static struct todo_item * append_new_todo (struct todo_list * todo_list )
24782478{
24792479 ALLOC_GROW (todo_list -> items , todo_list -> nr + 1 , todo_list -> alloc );
2480- todo_list -> total_nr ++ ;
24812480 return todo_list -> items + todo_list -> nr ++ ;
24822481}
24832482
@@ -2668,7 +2667,7 @@ int todo_list_parse_insn_buffer(struct repository *r, char *buf,
26682667 char * p = buf , * next_p ;
26692668 int i , res = 0 , fixup_okay = file_exists (rebase_path_done ());
26702669
2671- todo_list -> current = todo_list -> nr = 0 ;
2670+ todo_list -> current = todo_list -> nr = todo_list -> total_nr = 0 ;
26722671
26732672 for (i = 1 ; * p ; i ++ , p = next_p ) {
26742673 char * eol = strchrnul (p , '\n' );
@@ -2689,6 +2688,9 @@ int todo_list_parse_insn_buffer(struct repository *r, char *buf,
26892688 item -> commit = NULL ;
26902689 }
26912690
2691+ if (item -> command != TODO_COMMENT )
2692+ todo_list -> total_nr ++ ;
2693+
26922694 if (fixup_okay )
26932695 ; /* do nothing */
26942696 else if (is_fixup (item -> command ))
@@ -4270,7 +4272,7 @@ void todo_list_filter_update_refs(struct repository *r,
42704272 if (!is_null_oid (& rec -> after ))
42714273 continue ;
42724274
4273- for (j = 0 ; !found && j < todo_list -> total_nr ; j ++ ) {
4275+ for (j = 0 ; !found && j < todo_list -> nr ; j ++ ) {
42744276 struct todo_item * item = & todo_list -> items [j ];
42754277 const char * arg = todo_list -> buf .buf + item -> arg_offset ;
42764278
@@ -4300,7 +4302,7 @@ void todo_list_filter_update_refs(struct repository *r,
43004302 * For each todo_item, check if its ref is in the update_refs list.
43014303 * If not, then add it as an un-updated ref.
43024304 */
4303- for (i = 0 ; i < todo_list -> total_nr ; i ++ ) {
4305+ for (i = 0 ; i < todo_list -> nr ; i ++ ) {
43044306 struct todo_item * item = & todo_list -> items [i ];
43054307 const char * arg = todo_list -> buf .buf + item -> arg_offset ;
43064308 int j , found = 0 ;
@@ -6148,7 +6150,8 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
61486150 todo_list_to_strbuf (r , & new_todo , & buf2 , -1 , 0 );
61496151 strbuf_swap (& new_todo .buf , & buf2 );
61506152 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 ;
61526155 if (todo_list_parse_insn_buffer (r , new_todo .buf .buf , & new_todo ) < 0 )
61536156 BUG ("invalid todo list after expanding IDs:\n%s" ,
61546157 new_todo .buf .buf );
0 commit comments