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

Re: [PATCH 6/6] push: honor branch.*.push

From
Johan Herland <johan@herland.net>
Date
Jun 24, 2013, 15:23 UTC
Message-ID
<CALKQrgdQRtfGmfaq9sS=VbezV2RVs9WJwUQBqVF+1Ozn7FxdJw@mail.gmail.com>
In-Reply-To
<CALkWK0kqyV+MTW8jDDBt-qEB1R7yvD+n4nTxwvW0QjA13J2=2A@mail.gmail.com>

On Mon, Jun 24, 2013 at 4:19 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:

Show 16 quoted lines
> Junio C Hamano wrote:
>>>   # on branch master, derived from origin
>>>   $ git push ram
>>>
>>> And branch.master.push is set to next?  Will you let her shoot herself
>>> in the foot like this?
>>
>> It is not shooting in the foot, if branch.master.push is explicitly
>> set to update next.  I do not see any issue in that part.
>
> The question does not pertain to master being mapped to next; it
> pertains to central-workflow versus triangular-workflow: origin versus
> ram.  If the user has set push.default to upstream, she _expects_
> triangular pushes to always be denied, and this is the first violation
> of that rule.  I'm tilting towards building a dependency between
> branch.<name>.push and push.default.

I haven't followed this topic closely, and the concern described below is probably a consequence of that. Please ignore if my worries are unfounded.

It seems to me like we're adding (or have already added) quite a bit of config variables and command-line options for specifying (at varying levels of specificity and overridability) either the remote to push to ($remote), or what ref to push into on the remote ($remote_ref). It worries me that we allow $remote and $remote_ref to be set _separately_ and at separate levels of specificity. I wonder if this too easily allows users to shoot themselves in the foot by specifying $remote in one place (e.g. on the command line), then (in their mind - unrelated) specifying $remote_ref in another place (e.g. branch.foo.push), and then being negatively surprised when the two conspire to push into the "wrong" $remote and/or $remote_ref.

I haven't yet dug deep enough to figure out an obvious failure mode (and I probably should not have sent this email until I'd found one), but I wonder if we'd be better off forcing the $remote and $remote_ref configuration for a given branch to appear as more of a single unit.

What if, when setting up tracking for a given branch, we immediately specified its complete pull and push targets?

For example, when in a centralized workflow (e.g. push.default = upstream) and we're checking out local branch foo from origin's foo, we could set up the following configuration [1]:

[branch "foo"]
    pull = origin/foo
    push = origin/foo

In a triangular workflow (assuming we had configuration to specify such, and also a default push remote), we could then instead set up the following config:

[branch "foo"]
    pull = origin/foo
    push = my_public/foo

This leaves no ambiguity for even the most novice user as to the pull and push targets for a given branch, and it's also easy to change it, either by editing the config file directly, or by using hypothetical commands:

  git branch foo --pulls-from=origin/bar
  git branch foo --pushes-to=other_repo/foo

Any "git pull" without arguments will fail if branch.<current>.pull is unset or invalid. Likewise any "git push" without arguments will fail if branch.<current>.push is unset or invalid.

Obviously, specifying the remote and/or refspec on the command-line would still override, as it does today, but for the argument-less forms of "git pull" and "git push", the hierarchy of options and defaults being consulted to figure out $remote and $remote_ref would be small and easily understandable.

...Johan

[1]: I do realize that I'm abusing the "foo/bar" notation to mean "$remote/$ref", and that this does not work in the general case where both remote names and ref names may contain slashes, or when remote names don't correspond to eponymous ref namespaces...

-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Ramkumar RamachandraNext: Junio C Hamano
Message 26 of 36 in “Reroll of rr/triangular-push-fix”
  1. 0/6 Reroll of rr/triangular-push-fixJunio C Hamano, Jun 24, 2013
  2. 1/6 t/t5528-push-default: remove redundant test_config linesJunio C Hamano, Jun 24, 2013
  3. 2/6 config doc: rewrite push.default sectionJunio C Hamano, Jun 24, 2013
  4. 3/6 push: change `simple` to accommodate triangular workflowsJunio C Hamano, Jun 24, 2013
  5. Johan HerlandJun 24, 2013
  6. Junio C HamanoJun 24, 2013
  7. Ramkumar RamachandraJun 24, 2013
  8. Johan HerlandJun 24, 2013
  9. Ramkumar RamachandraJun 24, 2013
  10. Junio C HamanoJun 24, 2013
  11. Johan HerlandJun 24, 2013
  12. 4/6 t/t5528-push-default: generalize test_push_*Junio C Hamano, Jun 24, 2013
  13. Johan HerlandJun 24, 2013
  14. Junio C HamanoJun 24, 2013
  15. Johan HerlandJun 24, 2013
  16. Eric SunshineJun 24, 2013
  17. Johan HerlandJun 24, 2013
  18. Junio C HamanoJun 24, 2013
  19. 5/6 t/t5528-push-default: test pushdefault workflowsJunio C Hamano, Jun 24, 2013
  20. 6/6 push: honor branch.*.pushJunio C Hamano, Jun 24, 2013
  21. Johan HerlandJun 24, 2013
  22. Junio C HamanoJun 24, 2013
  23. Ramkumar RamachandraJun 24, 2013
  24. Junio C HamanoJun 24, 2013
  25. Ramkumar RamachandraJun 24, 2013
  26. Johan HerlandJun 24, 2013
  27. Junio C HamanoJun 24, 2013
  28. Junio C HamanoJun 24, 2013
  29. Ramkumar RamachandraJun 24, 2013
  30. Junio C HamanoJun 24, 2013
  31. Ramkumar RamachandraJun 24, 2013
  32. Junio C HamanoJun 24, 2013
  33. Ramkumar RamachandraJun 24, 2013
  34. Ramkumar RamachandraJun 24, 2013
  35. Junio C HamanoJun 24, 2013
  36. Ramkumar RamachandraJun 24, 2013

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.