From: Junio C Hamano <gitster@pobox.com>
To: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH 2/2] remote: resolve URL-valued push tracking remotes
Date: Mon, 20 Jul 2026 11:49:35 -0700 [thread overview]
Message-ID: <xmqq4ihtcx8g.fsf@gitster.g> (raw)
In-Reply-To: <ff645b21591a4b365b30acaf67a295510889141c.1784538618.git.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Mon, 20 Jul 2026 09:10:18 +0000")
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> A branch may name its push destination with a URL instead of a
> configured remote. This is useful in fork workflows, where the original
> remote is renamed to "upstream", the fork is added as "origin", and an
> existing branch.<name>.pushRemote continues to contain the fork URL.
>
> Git can still push through the anonymous remote created for that URL.
> However, the anonymous remote has no fetch refspec. Git therefore cannot
> resolve @{push} to origin/<branch> or update that remote-tracking branch
> after a push. The push can succeed, or report that everything is up to
> date, while status continues to compare against a stale tracking ref or
> cannot show the push branch at all.
Let me try to think aloud, rephrasing the explanation with a
slightly more concrete illustration, to see whether I understand
what you are trying to achieve.
The current system allows you to set:
[branch "mytopic"]
pushRemote = https://hosting.site/users/me/mine.git/
[remote "notlinked"]
url = https://hosting.site/users/me/mine.git/
push = refs/heads/mytopic
fetch = refs/heads/*:refs/remotes/notlinked/*
but when on the 'mytopic' branch, @{push} cannot determine which
branch at the remote repository to update, so it cannot map it back
to our remote-tracking branch ('refs/remotes/notlinked/mytopic' in
the above illustration).
A question. Do we currently accept a string that is not a remote
name as the value for 'branch.<name>.pushRemote' by design?
The 'git config --help' output explains that:
- 'branch.<name>.pushRemote' overrides 'branch.<name>.remote' and
'remote.pushDefault'; and
- 'branch.<name>.remote' and 'remote.pushDefault' tell 'git fetch'
and 'git push' which remote to work with.
It therefore seems clear that setting a string that is not a remote
name (such as a URL) as the value for these three variables is a
misconfiguration in the current system.
I am not saying that it should stay that way forever. But please
re-read your first sentence and tell me whether it is clear that the
patch extends the current system with a new feature. It was far
from clear to me and caused significant confusion. Writing it like
this:
Under the current system, a branch cannot name its push
destination using a URL. If we were to extend the system
to allow this, such and such benefits would become
possible.
would have been far less confusing.
If that is what you are doing, that is.
> A uniquely matching configured remote already provides the missing
> mapping.
A very good consideration. It was the first thing that came to my
mind while I was thinking aloud, constructing an illustration with
'notlinked', wondering "what if there is another remote, with the
same URL, but different 'push' configuration?".
> Use its fetch refspec when resolving the push tracking branch
> and when updating tracking refs after a push.
Is this not needless, and is mentioning it not confusing? If I
understand correctly, what the change entails is:
* If the value of 'branch.<name>.pushRemote' (call it X) is 'not' a
remote name, try to see whether there is a unique remote that
has either (1) a 'pushurl' whose value matches X, or (2) no
'pushurl' but a 'url' whose value matches X. If no such remote
exists, simply abort and refuse to proceed.
* If there is such a remote, pretend that the value of
'branch.<name>.pushRemote' were the name of that remote, and do
everything else as usual.
And mapping the current branch name to its push destination via
'remote.<name>.push' to find the name of the destination branch at
the remote, and then mapping it back to our remote-tracking branch
using 'remote.<name>.fetch', is not something new that this topic
needs to update, no?
Thanks. Once I understand what you are trying to achieve, I will
offer further comments on the implementation, as I find this topic
potentially quite interesting.
next prev parent reply other threads:[~2026-07-20 18:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 9:10 [PATCH 0/2] remote: resolve url push tracking Harald Nordgren via GitGitGadget
2026-07-20 9:10 ` [PATCH 1/2] remote: pass repository to push tracking helper Harald Nordgren via GitGitGadget
2026-07-20 18:23 ` Junio C Hamano
2026-07-20 9:10 ` [PATCH 2/2] remote: resolve URL-valued push tracking remotes Harald Nordgren via GitGitGadget
2026-07-20 18:49 ` Junio C Hamano [this message]
2026-07-20 19:56 ` Harald Nordgren
2026-07-20 23:49 ` Junio C Hamano
2026-07-21 8:58 ` [PATCH v2 0/2] remote: renamed remote push tracking Harald Nordgren via GitGitGadget
2026-07-21 8:58 ` [PATCH v2 1/2] remote: pass repository to push tracking helper Harald Nordgren via GitGitGadget
2026-07-21 8:58 ` [PATCH v2 2/2] remote: find tracking branches for URL push destinations Harald Nordgren via GitGitGadget
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=xmqq4ihtcx8g.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=haraldnordgren@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