Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Derrick Stolee <derrickstolee@github.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 2/2] rebase -r: fix the total number shown in the progress
Date: Thu, 11 May 2023 11:08:34 -0700	[thread overview]
Message-ID: <xmqqsfc2wxjx.fsf@gitster.g> (raw)
In-Reply-To: <b481d212-89c5-5c8e-c99f-6df3909523c7@gmail.com> (Phillip Wood's message of "Thu, 11 May 2023 15:13:44 +0100")

Phillip Wood <phillip.wood123@gmail.com> writes:

>> @@ -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.

>> @@ -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.

  reply	other threads:[~2023-05-11 18:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-10 22:55 [PATCH 0/2] Fix two rebase bugs related to total_nr Johannes Schindelin via GitGitGadget
2023-05-10 22:55 ` [PATCH 1/2] rebase --update-refs: fix loops Johannes Schindelin via GitGitGadget
2023-05-10 23:25   ` Junio C Hamano
2023-05-10 22:55 ` [PATCH 2/2] rebase -r: fix the total number shown in the progress Johannes Schindelin via GitGitGadget
2023-05-10 23:39   ` Junio C Hamano
2023-05-11 14:13   ` Phillip Wood
2023-05-11 18:08     ` Junio C Hamano [this message]
2023-05-13  8:11 ` [PATCH v2 0/2] Fix two rebase bugs related to total_nr Johannes Schindelin via GitGitGadget
2023-05-13  8:11   ` [PATCH v2 1/2] rebase --update-refs: fix loops Johannes Schindelin via GitGitGadget
2023-05-13  8:11   ` [PATCH v2 2/2] rebase -r: fix the total number shown in the progress Johannes Schindelin via GitGitGadget
2023-05-14 17:59   ` [PATCH v2 0/2] Fix two rebase bugs related to total_nr Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsfc2wxjx.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=phillip.wood123@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).