Subject: Re: [PATCH] status: show default branch comparison when tracking non-default branch

From: Harald Nordgren <[email-masked]>
Date: Tue, 23 Dec 2025 12:36:02 +0100

(Adding another comment to my own thread to reply to Junio C Hamano)

> branch.<name>.merge + branch.<name>.remote
> that defines where you pull from is one thing to compare with.  To
> learn the other, the destination of a push of this branch, would
> involve poking at remote.pushdefault, branch.<name>.pushRemote,
> branch.<name>.remote to find out which remote repository it goes,
> and then remote.<remote>.push to find out where this branch goes,
> but the helper functions to learn all that are already available.

When a new branch is created it has no push settings:

	git checkout -b ahead_of_main_status__tmp2

	git push
	fatal: The current branch ahead_of_main_status__tmp2 has no upstream branch.
	To push the current branch and set the remote as upstream, use

    	git push --set-upstream origin ahead_of_main_status__tmp2

	To have this happen automatically for branches without a tracking
	upstream, see 'push.autoSetupRemote' in 'git help config'.

Once the users runs that suggested command

	git push --set-upstream origin ahead_of_main_status__tmp2

then the 'branch.<name>.merge' and 'branch.<name>.remote' no longer hold the reference to "upstream/HEAD".

For sure, it would be great to re-use previous logic for this, but can it really be done without new logic?

Harald