git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [issue?]'git branch -D' case sensitive issue
@ 2016-01-14  7:52 郭腾飞
  2016-01-14 11:51 ` Torsten Bögershausen
  0 siblings, 1 reply; 6+ messages in thread
From: 郭腾飞 @ 2016-01-14  7:52 UTC (permalink / raw)
  To: git

Hi All,
I encountered some issues when using 'git branch -D'.
It's strange, the command 'git branch -D' is case sensitive.
Here is the operated log.

➜  my-emacs-conf git:(NIce) git branch -avv
* NIce                  fed5d9c Update js2-mode $ js-beautify.
  master                fed5d9c [origin/master] Update js2-mode $ js-beautify.
  remotes/origin/HEAD   -> origin/master
  remotes/origin/fake   8ec9cad fake.
  remotes/origin/mac13  13ae483 mac pro 13's config.
  remotes/origin/master fed5d9c Update js2-mode $ js-beautify.
➜  my-emacs-conf git:(NIce)
➜  my-emacs-conf git:(NIce) git branch -D NIce
error: Cannot delete the branch 'NIce' which you are currently on.
➜  my-emacs-conf git:(NIce)
➜  my-emacs-conf git:(NIce) git branch -D NICe
Deleted branch NICe (was fed5d9c).
➜  my-emacs-conf git:(NIce) ✗ git branch -avv
  master                fed5d9c [origin/master] Update js2-mode $ js-beautify.
  remotes/origin/HEAD   -> origin/master
  remotes/origin/fake   8ec9cad fake.
  remotes/origin/mac13  13ae483 mac pro 13's config.
  remotes/origin/master fed5d9c Update js2-mode $ js-beautify.

Hope someone can give me a hint.

➜  my-emacs-conf git:(NIce) ✗ git --version
git version 2.6.3
➜  my-emacs-conf git:(NIce) ✗ sw_vers -productVersion
10.11 OSX

BRs,
terry3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [issue?]'git branch -D' case sensitive issue
  2016-01-14  7:52 [issue?]'git branch -D' case sensitive issue 郭腾飞
@ 2016-01-14 11:51 ` Torsten Bögershausen
  2016-01-14 13:28   ` 郭腾飞
  0 siblings, 1 reply; 6+ messages in thread
From: Torsten Bögershausen @ 2016-01-14 11:51 UTC (permalink / raw)
  To: 郭腾飞, git

On 01/14/2016 08:52 AM, 郭腾飞 wrote:
> Hi All,
> I encountered some issues when using 'git branch -D'.
> It's strange, the command 'git branch -D' is case sensitive.
> Here is the operated log.
>
> ➜  my-emacs-conf git:(NIce) git branch -avv
> * NIce                  fed5d9c Update js2-mode $ js-beautify.
>    master                fed5d9c [origin/master] Update js2-mode $ js-beautify.
>    remotes/origin/HEAD   -> origin/master
>    remotes/origin/fake   8ec9cad fake.
>    remotes/origin/mac13  13ae483 mac pro 13's config.
>    remotes/origin/master fed5d9c Update js2-mode $ js-beautify.
> ➜  my-emacs-conf git:(NIce)
> ➜  my-emacs-conf git:(NIce) git branch -D NIce
> error: Cannot delete the branch 'NIce' which you are currently on.
> ➜  my-emacs-conf git:(NIce)
> ➜  my-emacs-conf git:(NIce) git branch -D NICe
> Deleted branch NICe (was fed5d9c).
> ➜  my-emacs-conf git:(NIce) ✗ git branch -avv
>    master                fed5d9c [origin/master] Update js2-mode $ js-beautify.
>    remotes/origin/HEAD   -> origin/master
>    remotes/origin/fake   8ec9cad fake.
>    remotes/origin/mac13  13ae483 mac pro 13's config.
>    remotes/origin/master fed5d9c Update js2-mode $ js-beautify.
>
> Hope someone can give me a hint.
>
> ➜  my-emacs-conf git:(NIce) ✗ git --version
> git version 2.6.3
> ➜  my-emacs-conf git:(NIce) ✗ sw_vers -productVersion
> 10.11 OSX
>
> BRs,
> terry3
> --
If you can give us a hint, under which OS you are working ?

I assume that you are on Windows or Mac OS ?
In this case the file system is part of the problem,
which treats NIce and NICe the same.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [issue?]'git branch -D' case sensitive issue
  2016-01-14 11:51 ` Torsten Bögershausen
@ 2016-01-14 13:28   ` 郭腾飞
  2016-01-14 16:42     ` Torsten Bögershausen
  0 siblings, 1 reply; 6+ messages in thread
From: 郭腾飞 @ 2016-01-14 13:28 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: git

Hi Torsten Bögershausen, thank you for the quick reply.
I'm working on Mac OS as I have mentioned in the previous email.

➜  my-emacs-conf git:(NIce) ✗ sw_vers -productVersion
10.11 OSX

And besides, I use a case sensitive file system in OSX through the command
'hdiutil create -volname 'case_fs' -type SPARSE -fs 'Case-sensitive
Journaled HFS+' -size 100g ~/case_fs.sparseimage'
Is this a known issue?
Thank you!

BRs
terry3

2016-01-14 19:51 GMT+08:00 Torsten Bögershausen <tboegi@web.de>:
> On 01/14/2016 08:52 AM, 郭腾飞 wrote:
>>
>> Hi All,
>> I encountered some issues when using 'git branch -D'.
>> It's strange, the command 'git branch -D' is case sensitive.
>> Here is the operated log.
>>
>> ➜  my-emacs-conf git:(NIce) git branch -avv
>> * NIce                  fed5d9c Update js2-mode $ js-beautify.
>>    master                fed5d9c [origin/master] Update js2-mode $
>> js-beautify.
>>    remotes/origin/HEAD   -> origin/master
>>    remotes/origin/fake   8ec9cad fake.
>>    remotes/origin/mac13  13ae483 mac pro 13's config.
>>    remotes/origin/master fed5d9c Update js2-mode $ js-beautify.
>> ➜  my-emacs-conf git:(NIce)
>> ➜  my-emacs-conf git:(NIce) git branch -D NIce
>> error: Cannot delete the branch 'NIce' which you are currently on.
>> ➜  my-emacs-conf git:(NIce)
>> ➜  my-emacs-conf git:(NIce) git branch -D NICe
>> Deleted branch NICe (was fed5d9c).
>> ➜  my-emacs-conf git:(NIce) ✗ git branch -avv
>>    master                fed5d9c [origin/master] Update js2-mode $
>> js-beautify.
>>    remotes/origin/HEAD   -> origin/master
>>    remotes/origin/fake   8ec9cad fake.
>>    remotes/origin/mac13  13ae483 mac pro 13's config.
>>    remotes/origin/master fed5d9c Update js2-mode $ js-beautify.
>>
>> Hope someone can give me a hint.
>>
>> ➜  my-emacs-conf git:(NIce) ✗ git --version
>> git version 2.6.3
>> ➜  my-emacs-conf git:(NIce) ✗ sw_vers -productVersion
>> 10.11 OSX
>>
>> BRs,
>> terry3
>> --
>
> If you can give us a hint, under which OS you are working ?
>
> I assume that you are on Windows or Mac OS ?
> In this case the file system is part of the problem,
> which treats NIce and NICe the same.
>



-- 

________________________________
Guo Tengfei

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [issue?]'git branch -D' case sensitive issue
  2016-01-14 13:28   ` 郭腾飞
@ 2016-01-14 16:42     ` Torsten Bögershausen
  2016-01-14 17:21       ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Torsten Bögershausen @ 2016-01-14 16:42 UTC (permalink / raw)
  To: 郭腾飞, Torsten Bögershausen; +Cc: git

On 14.01.16 14:28, 郭腾飞 wrote:
Please no top-posting on this list.
> Hi Torsten Bögershausen, thank you for the quick reply.
> I'm working on Mac OS as I have mentioned in the previous email.
> 
> ➜  my-emacs-conf git:(NIce) ✗ sw_vers -productVersion
> 10.11 OSX
> 
> And besides, I use a case sensitive file system in OSX through the command
> 'hdiutil create -volname 'case_fs' -type SPARSE -fs 'Case-sensitive
> Journaled HFS+' -size 100g ~/case_fs.sparseimage'
> Is this a known issue?
> Thank you!
> 
> BRs
> terry3

No, this is typically what we observe on a case insensitive FS.
And that make me wonder what
git config core.ignorecase
says ?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [issue?]'git branch -D' case sensitive issue
  2016-01-14 16:42     ` Torsten Bögershausen
@ 2016-01-14 17:21       ` Junio C Hamano
  2016-01-15 22:28         ` Jeff King
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2016-01-14 17:21 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: 郭腾飞, git

Torsten Bögershausen <tboegi@web.de> writes:

> No, this is typically what we observe on a case insensitive FS.

There is an interesting bit in delete_branches::builtin/branch.c

	if (kinds == FILTER_REFS_BRANCHES && !strcmp(head, bname.buf)) {
		error(_("Cannot delete the branch '%s' "
		      "which you are currently on."), bname.buf);
		ret = 1;
		continue;
	}

The strcmp() does not protect you from attempting to remove "FrOtZ"
branch when you are on (and more importantly, Git thinks you are on)
"frotz" branch.  A case-insensitive system then can tell Git that
the request to remove "refs/heads/FrOtZ" succeeded, even though in
reality it didn't have such file, and silently "refs/heads/frotz"
gets removed instead.  You can end up removing your current branch
that way.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [issue?]'git branch -D' case sensitive issue
  2016-01-14 17:21       ` Junio C Hamano
@ 2016-01-15 22:28         ` Jeff King
  0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2016-01-15 22:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Torsten Bögershausen, 郭腾飞, git

On Thu, Jan 14, 2016 at 09:21:46AM -0800, Junio C Hamano wrote:

> Torsten Bögershausen <tboegi@web.de> writes:
> 
> > No, this is typically what we observe on a case insensitive FS.
> 
> There is an interesting bit in delete_branches::builtin/branch.c
> 
> 	if (kinds == FILTER_REFS_BRANCHES && !strcmp(head, bname.buf)) {
> 		error(_("Cannot delete the branch '%s' "
> 		      "which you are currently on."), bname.buf);
> 		ret = 1;
> 		continue;
> 	}
> 
> The strcmp() does not protect you from attempting to remove "FrOtZ"
> branch when you are on (and more importantly, Git thinks you are on)
> "frotz" branch.  A case-insensitive system then can tell Git that
> the request to remove "refs/heads/FrOtZ" succeeded, even though in
> reality it didn't have such file, and silently "refs/heads/frotz"
> gets removed instead.  You can end up removing your current branch
> that way.

This seemed eerily familiar. And indeed, there's some discussion in:

  http://article.gmane.org/gmane.comp.version-control.git/276506

Changing that strcmp to strcmp_icase() is still wrong, though I suspect
it's less wrong in practice (and errs on the side of caution). But I
think there are probably a lot of similar problems lurking.

-Peff

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-01-15 22:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14  7:52 [issue?]'git branch -D' case sensitive issue 郭腾飞
2016-01-14 11:51 ` Torsten Bögershausen
2016-01-14 13:28   ` 郭腾飞
2016-01-14 16:42     ` Torsten Bögershausen
2016-01-14 17:21       ` Junio C Hamano
2016-01-15 22:28         ` Jeff King

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).