git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] rebase -r: fix the total number shown in the progress

From
Junio C Hamano <gitster@pobox.com>
Date
May 11, 2023, 18:08 UTC
Message-ID
<xmqqsfc2wxjx.fsf@gitster.g>
In-Reply-To
<b481d212-89c5-5c8e-c99f-6df3909523c7@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 25 quoted lines
>> @@ -2609,7 +2609,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');
>> @@ -2628,7 +2628,8 @@ int todo_list_parse_insn_buffer(struct repository *r, char *buf,
>>   			item->arg_offset = p - buf;
>>   			item->arg_len = (int)(eol - p);
>>   			item->commit = NULL;
>> -		}
>> +		} else if (item->command == TODO_COMMENT)
>> +			todo_list->total_nr--;
>
> This feels a bit fragile, I think it would be better to count the
> commands properly in the first place rather than adjusting the total
> here. We could do that by not incrementing "todo_list->total_nr" in
> append_new_todo() and then doing
>
> 	if (item->command != TODO_COMMENT)
> 		todo_list->total_nr++;
>
> here. We may want to stop counting invalid commands as well by only
> counting commands whre "item->command < TODO_COMMENT".
OK.
Show 27 quoted lines
>> @@ -6088,11 +6090,13 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
>>   		return -1;
>>   	}
>>   +	new_total_nr += count_commands(&new_todo);
>> +	new_todo.total_nr = new_total_nr;
>> +
>>   	/* Expand the commit IDs */
>>   	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;
>
> I think if we just change this line to
> 	
> 	new_todo.total_nr = 0;
>
> we don't need any other changes to this function. This is because
> complete_action() is only called at the start of a rebase so we don't
> need to worry about "total_nr" including commands that have already
> been executed. The reason we need to set it to zero here is that we
> re-parse the todo list below which increments "total_nr" by the number
> of commands parsed.
>
> Thanks for working on this.
> Best Wishes
>
> Phillip
Thanks both for working on the fix and reviewing the patch.
Previous: Phillip WoodNext: Johannes Schindelin via GitGitGadget
Message 7 of 11 in “Fix two rebase bugs related to total_nr”
  1. 0/2 Fix two rebase bugs related to total_nrJohannes Schindelin via GitGitGadget, May 10, 2023
  2. 1/2 rebase --update-refs: fix loopsJohannes Schindelin via GitGitGadget, May 10, 2023
  3. Junio C HamanoMay 10, 2023
  4. 2/2 rebase -r: fix the total number shown in the progressJohannes Schindelin via GitGitGadget, May 10, 2023
  5. Junio C HamanoMay 10, 2023
  6. Phillip WoodMay 11, 2023
  7. Junio C HamanoMay 11, 2023
  8. 0/2 Fix two rebase bugs related to total_nrJohannes Schindelin via GitGitGadget, May 13, 2023
  9. 1/2 rebase --update-refs: fix loopsJohannes Schindelin via GitGitGadget, May 13, 2023
  10. 2/2 rebase -r: fix the total number shown in the progressJohannes Schindelin via GitGitGadget, May 13, 2023
  11. Phillip WoodMay 14, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.