From: Junio C Hamano <gitster@pobox.com>
To: Jay Soffian <jaysoffian@gmail.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Jeff King <peff@peff.net>, Thomas Rast <trast@student.ethz.ch>,
Euguess@gmail.com, Mikael Magnusson <mikachu@gmail.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
git@vger.kernel.org, Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so
Date: Tue, 13 Oct 2009 20:28:56 -0700 [thread overview]
Message-ID: <7vfx9modqf.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <76718490910131805o42e8321ama85b90b7e901dc7d@mail.gmail.com> (Jay Soffian's message of "Tue\, 13 Oct 2009 21\:05\:54 -0400")
Jay Soffian <jaysoffian@gmail.com> writes:
> This doesn't help with the original problem, which was that a user
> attempted to checkout refs/remotes/origin/<name> by just saying 'git
> checkout <name>' which I happen to think should work. A lot of what I
> keep hearing in this thread seems to be in the vein of the perfect
> being the enemy of the good.
I do not think there is "perfect" nor "good" anywhere in this. It is just
the proposals were either not well thought out, were not presented well,
or were misunderstood, or a bit of all.
When you do not have local "frotz" branch, and do have cloned/fetched from
the origin that has "frotz" branch, I am actually Ok with this
$ git checkout frotz [--]
to do an equivalent of:
$ git checkout -t -b frotz origin/frotz
I do not have problem with this _particular_ DWIMmery. It will not break
people's expectations, other than "asking to check out non-existing ref
should fail". That expectation might be logical, but I do not think it is
useful.
Another reason I won't have problem with this one is that perhaps after
creating a few more commits, the next day when the user does the same
$ git checkout frotz
what will be shown is the _local_ frotz branch. Nowhere in this sequence
there is any room to mistake that you somehow checked out a branch owned
by somebody else (namely, origin). You started by auto-creating your
local branch, worked on it, and checked it out again the next day. In
other words, this is really about a shorthand to create a new local branch
called "frotz" when the commit that the branch should start from is
clearly unambiguous.
I have trouble with yours, on the other hand, which is to make
$ git checkout origin/frotz
$ git checkout v1.5.5
into
$ git checkout -b frotz-47 origin/frotz
$ git checkout -b v1.5.5-47 v1.5.5
(replace -47 with whatever random string you would come up with to make it
unique), as it _will_ break people's expectations, and the expected
behaviour to detach without polluting the local branch namespace for
the purpose of sightseeing happens to be a useful one.
I also have issues with turning
$ git checkout origin/frotz
into
$ git checkout -b frotz origin/frotz
only when frotz does not exist locally. This will cause the "next day"
problem, and also by naming the remote tracking branch, gives a wrong
impression that this is about a remote branch. It should not be.
Perhaps without touching the "detached" case at all, if we limit the scope
of the change that comes out of this discussion to only one case, it might
result in a good trouble-free enhancement [*1*].
The new rule would be:
"git checkout $name", when all of the following holds:
- $name is a good name for a local branch (i.e. check-ref-format is
happy);
- No local branch of that name exists;
- There is exactly one remote $remote that has $name branch; and
- $name itself is not a good commit name (i.e. get_sha1() barfs)
is a request to create a local branch $name, and the branch tracks the
remote tracking branch found in the third condition [*2*].
The important point here is that this exception is _not_ about remote
tracking branch but is about a rule to allow omitting -b to create and
checkout a local branch when the user's intent is clear that (1) he wants
to create a new one named $name, and (2) he wants to create it starting at
the commit $remote/$name.
Such a change feels quite safe and I wouldn't be opposed to it.
We _could_ discuss extending the $name in the above rule to other kinds
(tags and even arbitrary committish that may not even have a direct ref
pointing at it), but I think they are much more problematic.
[Footnote]
*1* Yes, I know I won't try to come with a strawman.
*2* The fourth condition is to avoid taking "origin/frotz" when "origin"
remote has "frotz" branch _and_ "other" remote has "origin/frotz" branch.
The remote chosen by the third condition would be "other" (because
"origin" remote only has "frotz", and not "origin/frotz", the name is
unique in the sense of the third condition). The fourth condition
prevents this from happening, and forbids an explicit request to detach
HEAD at one point (i.e. "origin/frotz") from triggering.
next prev parent reply other threads:[~2009-10-14 3:32 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-05 20:46 [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so Jay Soffian
2009-10-05 21:03 ` Sverre Rabbelier
2009-10-05 21:17 ` Johannes Schindelin
2009-10-05 21:26 ` Sverre Rabbelier
2009-10-05 21:57 ` Jay Soffian
2009-10-05 22:00 ` Jay Soffian
2009-10-05 22:45 ` Johannes Schindelin
2009-10-05 22:56 ` Jeff King
2009-10-06 7:32 ` Thomas Rast
2009-10-06 9:16 ` Johannes Schindelin
2009-10-06 11:36 ` Junio C Hamano
2009-10-06 12:02 ` Johannes Schindelin
2009-10-06 20:09 ` Junio C Hamano
2009-10-06 9:12 ` Johannes Schindelin
2009-10-06 9:28 ` Matthieu Moy
2009-10-06 9:41 ` Mikael Magnusson
2009-10-06 10:04 ` Johannes Schindelin
[not found] ` <0016e68fd0123a175304754694b4@google.com>
2009-10-06 16:43 ` Eugene Sajine
2009-10-06 20:33 ` Junio C Hamano
2009-10-12 7:49 ` Johannes Schindelin
2009-10-12 18:36 ` Björn Steinbrink
2009-10-12 21:40 ` Thomas Rast
2009-10-12 22:49 ` Junio C Hamano
2009-10-13 6:36 ` Thomas Rast
2009-10-13 7:16 ` Junio C Hamano
2009-10-13 8:44 ` Junio C Hamano
2009-10-13 8:51 ` Thomas Rast
2009-10-13 9:24 ` Junio C Hamano
2009-10-13 21:20 ` Johannes Schindelin
2009-10-13 21:59 ` Junio C Hamano
2009-10-13 22:06 ` Jeff King
2009-10-13 23:22 ` Johannes Schindelin
2009-10-14 1:05 ` Jay Soffian
2009-10-14 3:28 ` Junio C Hamano [this message]
2009-10-14 12:49 ` Jay Soffian
2009-10-14 19:31 ` Junio C Hamano
2009-10-25 17:44 ` Uri Okrent
2009-10-14 4:31 ` Jeff King
2009-10-14 9:56 ` Thomas Rast
2009-10-14 10:46 ` Jakub Narebski
2009-10-13 9:32 ` Johannes Sixt
2009-10-13 18:39 ` Daniel Barkalow
2009-10-13 20:53 ` Junio C Hamano
2009-10-13 21:31 ` Daniel Barkalow
2009-10-13 21:57 ` Jeff King
2009-10-13 22:46 ` Junio C Hamano
2009-10-13 23:16 ` Johannes Schindelin
2009-10-14 9:33 ` Thomas Rast
2009-10-16 11:48 ` Johannes Schindelin
2009-10-16 12:07 ` Thomas Rast
2009-10-25 17:48 ` Uri Okrent
2009-10-26 7:14 ` Junio C Hamano
2009-10-13 22:38 ` Björn Steinbrink
2009-10-18 7:58 ` Junio C Hamano
2009-10-18 8:00 ` [PATCH 1/3] check_filename(): make verify_filename() callable without dying Junio C Hamano
2009-10-18 8:01 ` [PATCH 2/3] DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz" Junio C Hamano
2009-10-18 10:34 ` Nanako Shiraishi
2009-10-18 12:00 ` Björn Steinbrink
2009-10-18 20:20 ` Nanako Shiraishi
2009-10-18 22:50 ` Junio C Hamano
2009-10-19 5:58 ` Björn Steinbrink
2009-10-18 8:01 ` [PATCH 3/3] git checkout --nodwim Junio C Hamano
2009-10-18 12:40 ` Alex Riesen
2009-10-18 19:53 ` Junio C Hamano
2009-10-18 21:02 ` [PATCH] Use "--no-" prefix to switch off some of checkout dwimmery Alex Riesen
2009-10-18 22:49 ` Junio C Hamano
2009-10-19 6:07 ` Alex Riesen
2009-10-19 6:12 ` Alex Riesen
2009-10-19 6:16 ` Junio C Hamano
2009-10-19 7:17 ` Alex Riesen
2009-10-19 7:25 ` Junio C Hamano
2009-10-21 17:29 ` [PATCH 3/3] git checkout --nodwim Avery Pennarun
2009-10-21 21:21 ` Nanako Shiraishi
2009-10-21 22:14 ` Junio C Hamano
2009-10-21 22:35 ` [PATCH] git checkout --no-guess Junio C Hamano
2009-10-21 22:51 ` Avery Pennarun
2009-10-26 18:17 ` Jay Soffian
2009-10-26 18:25 ` Avery Pennarun
2009-10-22 0:27 ` [PATCH 3/3] git checkout --nodwim Johannes Schindelin
2009-10-22 7:09 ` Erik Faye-Lund
2009-10-23 8:57 ` Michael J Gruber
2009-10-24 6:35 ` Junio C Hamano
2009-10-24 14:59 ` David Roundy
2009-10-24 19:25 ` Junio C Hamano
2009-10-26 20:12 ` Johannes Schindelin
2009-10-26 20:40 ` Avery Pennarun
2009-10-26 21:26 ` Jeff King
2009-10-26 22:01 ` Avery Pennarun
2009-10-26 22:14 ` Jeff King
2009-10-26 22:28 ` Avery Pennarun
2009-10-05 22:52 ` [PATCH/RFC] builtin-checkout: suggest creating local branch when appropriate to do so Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vfx9modqf.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Euguess@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=jaysoffian@gmail.com \
--cc=mikachu@gmail.com \
--cc=peff@peff.net \
--cc=trast@student.ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.