Re: push.default: current vs upstream
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Apr 7, 2012, 07:49 UTC
- Message-ID
- <4F7FF19B.1060407@alum.mit.edu>
- In-Reply-To
- <20120406080004.GA27940@sigill.intra.peff.net>
The very subject of this email is leading the discussion in circles.
Neither current nor upstream is safe for beginners because there are distinct workflows that require different behaviors in scenarios that git cannot distinguish.
On 04/06/2012 10:00 AM, Jeff King wrote:
Show 8 quoted lines
> On Fri, Apr 06, 2012 at 09:44:48AM +0200, Matthieu Moy wrote: > [...] >> About safety, I don't think we can tell in general which bad push is the >> most serious. push.default=current may create branches unexpectedly, >> while push.default=upstream would ask you to "push --set-upstream" when >> creating the remote branch. push.default=upstream may push to the master >> when you wanted to create a remote topic branch. My feeling is that both >> are equally bad, but maybe I'm wrong here.
Exactly. Choosing between "current vs upstream" is a false dichotomy.
Let's create a new "push.default" option (call it "beginner" for the sake of discussion) that is intended for use *only* for people who haven't explicitly chosen another alternative. Let the "beginner" option do the obvious thing when it is uncontroversial and undangerous, and let it output a beginner-level help message in any scenarios where the right thing to do is not obvious. The help message should basically recommend that the user run "git config push.default VALUE" and explain the meaning of the possible VALUEs.
If "push.default" is not set, then have it default to "beginner" mode.
Show 9 quoted lines
> On the other hand, one thing we have not talked about is how one gets > into the "topic push fast-forwards master" situation. Which is running: > > $ git checkout -b topic origin/master > > I'm not sure if that is something totally clueless people will run. And > maybe by the time people are intermediate enough git users to run that, > they will have figured out how upstream works. So maybe my concern is > overblown.
When the "beginner" option is active, this case should trigger the informational help message because git cannot know for sure what the user wants.
> I consider the much more likely scenarios for a new user to
Show 14 quoted lines
> be: > > $ git clone ...&& cd project > $ hack hack hack > $ git push > > which will work with either "current" or "upstream", or: > > $ git clone ...&& cd project > $ git checkout foo ;# equivalent of "git checkout -b foo origin/foo" > $ hack hack hack > $ git push > > which also works with both
Since the first two scenarios are uncontroversial, the "beginner" option should do the expected thing.
> or:
Show 8 quoted lines
> > $ git clone ...&& cd project > $ git checkout -b topic > $ hack hack hack > $ git push > > which will error out for "upstream", and create a new branch "topic" on > the remote with "current".
The correct behavior in the above scenario depends on the workflow, so the "beginner" option should not do anything except supply help information.
Michael
-- Michael Haggerty mhagger@alum.mit.edu http://softwareswirl.blogspot.com/