All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dennis Kaarsemaker <dennis@kaarsemaker.net>
To: git@vger.kernel.org
Subject: [Bug] incomplete defence agains creating a branch named HEAD
Date: Wed, 05 Aug 2015 17:46:17 +0200	[thread overview]
Message-ID: <1438789577.17587.7.camel@kaarsemaker.net> (raw)

So git branch doesn't like to create a branch named HEAD

$ git branch HEAD
fatal: it does not make sense to create 'HEAD' manually

But, you can trick it into doing so anyway:

$ git branch @
$ git branch -a
  HEAD
* master

At which point git status becomes a bit confused:

$ git status
warning: refname 'HEAD' is ambiguous.
warning: refname 'HEAD' is ambiguous.
On branch master
nothing to commit, working directory clean

Oh, and git checkout will accept either HEAD or @ to create a branch
with the name HEAD anyway:

$ git checkout -b HEAD
Switched to a new branch 'HEAD'

$ git checkout -b @
Switched to a new branch 'HEAD'

imho none of these should create a branch named HEAD, but should do what
'git branch HEAD' does and fail with a sensible error message.

All these shenanigans came up when trying to help an user who is
mirroring a mercurial repo that has a branch named '@'. Whether or not
git should allow branches named '@' I don't have an opinion on, I know
'@' is pretty special when dealing with refs.

-- 
Dennis Kaarsemaker
www.kaarsemaker.net

                 reply	other threads:[~2015-08-05 15:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1438789577.17587.7.camel@kaarsemaker.net \
    --to=dennis@kaarsemaker.net \
    --cc=git@vger.kernel.org \
    /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.