Subject: Re: Another look?

From: Phillip Wood <[email-masked]>
Date: Sat, 3 Jan 2026 10:04:01 +0000

On 02/01/2026 20:27, Harald Nordgren wrote:
> 
>> Shouldn't we be taking account of the push and fetch refspecs here? There
>> is no guarantee that $branch maps to refs/remotes/$remote/$branch. To take
>> a silly example, if we have
>>
>>       remote.$remote.fetch =
>> refs/heads/$branch:refs/remotes/$remote/abc-$branch remote.$remote.pull =
>> refs/heads/$branch:refs/heads/xyz-$branch
>>
>> Then we should be using "refs/remotes/$remote/abc-xyz-$branch" in the
>> message above as "$branch" will be pushed to "xyz-$branch" on the remote
>> which is fetched to "$remote/abc-xyz-$branch"
> 
> I don't understand this one, can you maybe explain how to code will need to
> change?

You want to display the remote tracking ref that tracks ref on the 
remote that we push to. When git pushes $branch to $remote it checks if 
any of the push refspecs remote.$remote.push match $branch. If there is 
a match then the branch name is mapped according to the refspec and that 
it the ref that is updated in the remote repository. It then takes that 
ref and checks the fetch refspecs remote.$remote.fetch and if it finds a 
match it maps the ref we've pushed to a remote tracking ref in the local 
repository.

It looks like you can find where we would push a branch to with 
remote_ref_for_branch() and you can map that to a remote tracking ref 
with tracking_for_push_dest(). We could use branch_get_push() but does 
more than just map the refs as it checks push.default to see whether 
"git push" would actually push the branch.

Thanks

Phillip