From: Jeff King <peff@peff.net>
To: Mark Levedahl <mlevedahl@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] builtin-branch - allow deleting a fully specified branch-name
Date: Sun, 12 Apr 2009 03:20:57 -0400 [thread overview]
Message-ID: <20090412072056.GA25837@coredump.intra.peff.net> (raw)
In-Reply-To: <200904111301.31250.mlevedahl@gmail.com>
On Sat, Apr 11, 2009 at 01:01:30PM -0400, Mark Levedahl wrote:
> $ git checkout -b refs/heads/master refs/heads/master
> creates a new branch, refname = refs/heads/refs/heads/master
>
> The last command is the one that I find most curious. The exact same string
> has two entirely different meanings to the same command. I can explain why
> this happens, but I cannot explain why this is a good thing.
A command like "grep foo foo" has the same property (one string with
different meanings based on argument position). The problem is that you
are thinking of it as:
git checkout -b <branch> <branch>
And I can see why you might think of it that way, because that is what
the synopsis in git-checkout(1) says. :) But it is really:
git checkout -b <branch> <commit>
I'm not sure if changing that synopsis would really help, or if it is
a bit too subtle.
> A model I could explain without mental gymnastics would be "branch names are
> simply refnames without the leading refs/heads or refs/remotes, and a refname
> may be used wherever a branch name is requested. While branch names are
> potentially ambiguous, refnames never are." Of course, this would mean that
So the current model is: "branch names are simply refnames without the
leading refs/heads or refs/remotes. A <commit> can be referenced by the
usual names (see git rev-parse, "specifying revisions" for details)".
The thing that I think is more confusing about that is not the
final example you pointed out, but the difference between
git checkout master
and
git checkout refs/heads/master
Which is explained by the fact that the usage for checkout is not
git checkout <branch>
but actually
git checkout <branch|commit>
If a branch, then we checkout the branch. If a commit, then we detach on
that commit.
I'm not sure if that explanation helps you at all, but that is how I
think of it (and it makes sense to me).
-Peff
next prev parent reply other threads:[~2009-04-12 7:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-10 0:28 [PATCH] builtin-branch - allow deleting a fully specified branch-name Mark Levedahl
2009-04-10 0:39 ` Junio C Hamano
2009-04-10 1:19 ` Mark Levedahl
2009-04-10 3:18 ` Junio C Hamano
2009-04-11 17:01 ` Mark Levedahl
2009-04-12 7:20 ` Jeff King [this message]
2009-04-12 8:22 ` Junio C Hamano
2009-04-13 8:56 ` Jeff King
2009-04-13 9:54 ` Junio C Hamano
2009-04-13 11:09 ` Jeff King
2009-04-13 11:11 ` [PATCH 1/5] doc: clarify --no-track option Jeff King
2009-04-13 11:11 ` [PATCH 2/5] doc: refer to tracking configuration as "upstream" Jeff King
2009-04-13 11:18 ` [PATCH 3/5] doc/checkout: refer to git-branch(1) as appropriate Jeff King
2009-04-13 11:19 ` [PATCH 4/5] doc/checkout: split checkout and branch creation in synopsis Jeff King
[not found] ` <fabb9a1e0904130613g5b664706jb6a3c29107ac1fc9@mail.gmail.com>
2009-04-13 13:19 ` Jeff King
2009-04-13 13:21 ` Sverre Rabbelier
2009-04-13 11:21 ` [PATCH 5/5] docs/checkout: clarify what "non-branch" means Jeff King
2009-04-13 16:31 ` Junio C Hamano
2009-04-14 3:40 ` Mark Levedahl
2009-04-14 4:20 ` Junio C Hamano
2009-04-14 11:36 ` Jakub Narebski
2009-04-15 18:00 ` Jeff King
2009-04-15 17:58 ` Jeff King
2009-04-13 10:57 ` [PATCH] builtin-branch - allow deleting a fully specified branch-name 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=20090412072056.GA25837@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mlevedahl@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).