git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug: git branch -D can be used to delete branch which is currently checked out

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 10, 2016, 17:40 UTC
Message-ID
<xmqqvb4udyf9.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CE5AE06C-0909-414E-B901-7CCF3A259465@gmail.com>
Marcus Kida <marcus.kida@gmail.com> writes:
Show 7 quoted lines
> Testes on: 
>
> Mac OS X 10.11.3 (El Capitan) using Git 2.6.4
>
> Issue:
>
> git branch -D can be used to delete branch which is currently checked out

There are other limitations a filesystem that is incapable of differentiating two files with names that are only different in case imposes on your use of Git, e.g.

 - "git fetch origin", when the origin repository has two tags 'v1'
   and 'V1', may not let you have both of these tags locally;
 - "git checkout Another", when the branch you have is 'another',
   may check it out instead of complaining (replace "checkout" with
   any other command that let you use a refname to specify an object).

It is a possibility to teach the files backend of refs API that some filesystems are case insensitive and do something special about them, but I think in the longer term a more productive solution would be to use the upcoming "pluggable ref backend" subsystem and either

 - use a backend that is not the "files" backend (e.g. lmdb backend,
   or the tree-object based backend);
 - add a variant of "files" backend but encodes the refnames in a
   way that is safe on case insensitive filesystems.

That way, those on platforms with case insensitive filesystems do not have to be artificially limited. Git is about working together with people potentially on other systems, and "on this system you cannot have 'master' and 'Master' at the same time, because we have a patch to case-fold the refnames" would not be a good longer term solution.

Previous: Marcus KidaNext: Junio C Hamano
Message 2 of 4 in “Bug: git branch -D can be used to delete branch which is currently checked out”
  1. Marcus KidaMar 10, 2016
  2. Junio C HamanoMar 10, 2016
  3. Junio C HamanoMar 10, 2016
  4. Marcus KidaMar 10, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.