Re: Another look?
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 5, 2026, 22:13 UTC
- Message-ID
- <xmqq5x9flndb.fsf@gitster.g>
- In-Reply-To
- <20260105131654.88348-1-haraldnordgren@gmail.com>
Harald Nordgren <haraldnordgren@gmail.com> writes:
Show 9 quoted lines
>> Please don't. Unless my assumption, which is that in the old code >> "!sti" and "!ours && !theirs" is equivalent, is wrong, all you need >> to do around that part is to first check "if (!ours && !theirs)" and >> say "your branch is up to date with...", and then have the check >> "else if (abf == ABQ)" next. That way, when we check abf we know >> the branches are different. > > It seems to be an incorrect assumption. This code change breaks several > tests including old ones:
Show 19 quoted lines
>
> ```
> diff --git a/remote.c b/remote.c
> index 1f87b85b22..8db4fcd7b5 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -2303,7 +2303,7 @@ static void format_branch_comparison(struct strbuf *sb,
> enum branch_mode_flags advice_flags,
> int show_divergence_advice)
> {
> - if (!sti) {
> + if (!ours && !theirs) {
> strbuf_addf(sb,
> _("Your branch is up to date with '%s'.\n"),
> branch_name);
> ```
>
>
> HaraldThat is unexpected.
Looking at what stat_branch_pair() does, before returning 0, the function always clears *num_theirs and *num_ours, so there is something else going on.
If your caller is *not* initializing ours and theirs, and if it is not detecting an error return from stat_tracking_info, and the test code is trying to see when stat_branch_info() signals failure by returning -1, then I can understand why the above change makes a difference (i.e., your code above with or without sti -> ours/theirs change is broken), but then, that should be handled at the caller of stat_tracking_info() by noticing its return value being negative, I would have to say.