git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
Jan 13, 2014, 20:27 UTC
Message-ID
<20140113202730.GA32542@sigill.intra.peff.net>
In-Reply-To
<xmqqtxd763lf.fsf@gitster.dls.corp.google.com>
On Mon, Jan 13, 2014 at 12:15:08PM -0800, Junio C Hamano wrote:
Show 9 quoted lines
> Jeff King <peff@peff.net> 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'?".

Right. I wondered at first if there was a similar bug in @{upstream}, but as I noted earlier, it is not defined if a per-branch remote is not set. The answer to your question above is "nothing", so we do not have to worry about it. :)

Show 5 quoted lines
> 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.

Yes, that is what I tried for with my original patches. (e.g., "push.default=upstream" should just make @{publish} a synonym for @{upstream}, which is what my patch did). I punted on "simple", but it would ideally do the same thing as "push". Which is why I do not think my patches are appropriate as-is; they need to somehow share the logic with "git push" rather than try to reimplement it.

Show 10 quoted lines
> 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.

Right. And my patches did that (or at least I intended them to :) ) by applying the push refspec (if any), and then applying the fetch refspec on top of that. But again, that seems like policy that should be shared with "git push".

That being said, I do not think your example is the best one for @{publish}. You have not specified any remote at all. I think the closest "push" behavior for @{publish} would be something like:

  git checkout master && git push
I.e., where would _that_ push go?
Show 24 quoted lines
> 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.

Exactly. I do not think the multiple push destinations matter here, because it is always "what would I do if I were on the branch". At most one of them can be the default in that case (based on the config as you noted).

-Peff
Previous: Junio C Hamano
Message 9 of 9 in “Minor preparation for @{publish}”
  1. 0/3 Minor preparation for @{publish}Ramkumar Ramachandra, Jan 12, 2014
  2. 1/3 t1507 (rev-parse-upstream): fix typo in test titleRamkumar Ramachandra, Jan 12, 2014
  3. 2/3 interpret_branch_name: factor out upstream handlingRamkumar Ramachandra, Jan 12, 2014
  4. 3/3 remote: introduce and fill branch->pushremoteRamkumar Ramachandra, Jan 12, 2014
  5. Jeff KingJan 13, 2014
  6. Ramkumar RamachandraJan 13, 2014
  7. Jeff KingJan 13, 2014
  8. Junio C HamanoJan 13, 2014
  9. Jeff KingJan 13, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.