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:
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.
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
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:
$ 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@xxxxxxxxxxxx
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html