Subject: Re: [PATCH 3/3] remote: introduce and fill branch->pushremote

From: Junio C Hamano <[email-masked]>
Date: Mon, 13 Jan 2014 12:15:08 -0800

Jeff King <[email-masked]> writes:

> It does not matter for actually pushing, because to do a non-default
> push, you must always specify a remote. But "@{publish}" will ask the
> question "even if I am on 'side' now, what would happen if I were to
> default-push on 'master'?".

In a similar wording to yours, it can be said that B@{upstream} is
"what would happen if I were to default-pull on 'B'?".

A related tangent is what should B@{publish} should yield when there
is no triangular configuration variables like remote.pushdefault,
branch.B.pushremote and a possible future extension branch.B.push
are defined.  The definition you gave, i.e. "if I were to
default-push", gives a good guideline, I think.

I.e. "git push origin master" does tell us to push out 'master', but
it does not explicitly say what ref to update.  It may be set to
update their remotes/satellite/master when we are emulating a fetch
in reverse by pushing, via e.g.

	[remote "origin"]
        	push = refs/heads/master:refs/remotes/satellite/master

and it would be intuitive if we make "master@{publish}" resolve to
"refs/remotes/satellite/master" in such a case.

One thing that makes things a bit fuzzy is what should happen if
you have more than one push destinations.  For example:

	[remote "home"]
        	pushurl = ...
                push = refs/heads/master:refs/remotes/satellite/master

	[remote "github"]
        	pushurl = ...
                mirror

	[remote]
        	pushdefault = ???

"git push home" updates their 'refs/remotes/satellite/master' with
my 'master' with the above, while "git push github" will update
their 'refs/heads/master' with 'master'.

We can say master@{publish} is 'remotes/satellite/master' if
remote.pushdefault (or 'branch.master.pushremote") is set to 'home',
it is 'master' if it is 'github', and if "git push" while sitting on
'master' does not push it anywhere then master@{publish} is an
error.  There may be a better definition of what "if I were to
default-push" really means, but I don't think of any offhand.