From: Junio C Hamano <gitster@pobox.com>
To: Mark Levedahl <mlevedahl@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] builtin-branch - allow deleting a fully specified branch-name
Date: Thu, 09 Apr 2009 20:18:01 -0700 [thread overview]
Message-ID: <7vbpr519jq.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <200904092119.10520.mlevedahl@gmail.com> (Mark Levedahl's message of "Thu, 9 Apr 2009 21:19:09 -0400")
Mark Levedahl <mlevedahl@gmail.com> writes:
> On Thursday 09 April 2009 20:39:46 Junio C Hamano wrote:
>> Mark Levedahl <mlevedahl@gmail.com> writes:
>> > This change allows, for instance
>> > git branch -d refs/heads/foo
>> > to succeed. Without this patch, the code just assumes that the
>> > given branch name should be appended to "refs/heads" or
>> > "refs/remotes", thus attempting (and failing) in the above case
>> > to delete "refs/heads/refs/heads/foo"
>>
>> Your logic is broken.
>>
>> Why doesn't the user simply say "git branch -d foo"? The command takes
>> "the branch name", not "arbitrary ref name".
>
> 1) git branch -d refs/<whatever> used to work, I haven't bisected to find
> when this stopped working, but the change broke one of my scripts, so this is
> not new behavior, it is restoration of previous behavior.
I need to look at the history, if that is the case then perhaps Ok.
> 2) If I create branch refs/frotz/bar , how do I ever delete it?
By this you must mean .git/refs/heads/refs/frotz/bar, right? Then
shouldn't "git branch -d refs/frotz/bar" just work as is? If you are
talking about .git/refs/frotz/bar, "git branch" should not touch it, it is
not even a branch.
> Also, the following all work
> 3) git branch refs/heads/foo
> 4) git branch -m refs/heads/foo refs/heads/bar
If you mean it creates .git/refs/heads/refs/heads/foo, then sure it
should. If it creates .git/refs/heads/foo, I think it is broken.
> 5) git [checkout|pull|push|fetch|show] refs/heads/foo
Among these, checkout is the only special case that can take "branch name"
to switch branches. Everything else takes extended SHA-1 expression.
Checkout can interpret the first argument as "branch to switch to", but it
does not necessarily so---think "detached HEAD", and also think "checking
out paths out of tree-ish".
> So, why is "git branch -d" so special?
"git branch -d", "git branch -m" and friends all take branch name, and as
such it can use "@{-1}" to _name_ 'the previous branch". In that context,
you are _not_ naming the commit at the tip of the branch. You are naming
the branch itself.
All other commands happen to take a branch name because that is just one
case of extended SHA-1 expression to name an object. In that context, a
refname (which a branch name is a special case of) refers to the commit
pointed by it. E.g.
"git checkout HEAD~20 -- Makefile"
"git show refs/heads/foo"
"git show heads/foo"
"git show foo"
next prev parent reply other threads:[~2009-04-10 3:19 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 [this message]
2009-04-11 17:01 ` Mark Levedahl
2009-04-12 7:20 ` Jeff King
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=7vbpr519jq.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--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).