All of lore.kernel.org
 help / color / mirror / Atom feed
* Branch deletion question / possible bug?
@ 2018-04-28  0:29 Tang (US), Pik S
  2018-04-28  7:44 ` Jacob Keller
  0 siblings, 1 reply; 5+ messages in thread
From: Tang (US), Pik S @ 2018-04-28  0:29 UTC (permalink / raw)
  To: git

Hi,

I discovered that I was able to delete the feature branch I was in, due to some fat fingering on my part and case insensitivity.  I never realized this could be done before.  A quick google search did not give me a whole lot to work with...  

Steps to reproduce:
1. Create a feature branch, "editCss"
2. git checkout master
3. git checkout editCSS
4. git checkout editCss
5. git branch -d editCSS

Normally, it should have been impossible for a user to delete the branch they're on.  And the deletion left me in a weird state that took a while to dig out of.

I know this was a user error, but I was also wondering if this was a bug.


Thanks,

Pik Tang


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

* Re: Branch deletion question / possible bug?
  2018-04-28  0:29 Branch deletion question / possible bug? Tang (US), Pik S
@ 2018-04-28  7:44 ` Jacob Keller
  2018-04-28 10:30   ` Philip Oakley
  0 siblings, 1 reply; 5+ messages in thread
From: Jacob Keller @ 2018-04-28  7:44 UTC (permalink / raw)
  To: Tang (US), Pik S; +Cc: git

On Fri, Apr 27, 2018 at 5:29 PM, Tang (US), Pik S <Pik.S.Tang@boeing.com> wrote:
> Hi,
>
> I discovered that I was able to delete the feature branch I was in, due to some fat fingering on my part and case insensitivity.  I never realized this could be done before.  A quick google search did not give me a whole lot to work with...
>
> Steps to reproduce:
> 1. Create a feature branch, "editCss"
> 2. git checkout master
> 3. git checkout editCSS
> 4. git checkout editCss
> 5. git branch -d editCSS
>

Are you running on a case-insensitive file system? What version of
git? I thought I recalled seeing commits to help avoid creating
branches of the same name with separate case when we know we're on a
file system which is case-insensitive..

> Normally, it should have been impossible for a user to delete the branch they're on.  And the deletion left me in a weird state that took a while to dig out of.
>
> I know this was a user error, but I was also wondering if this was a bug.

If we have not yet done this, I think we should. Long term this would
be fixed by using a separate format to store refs than the filesystem,
which has a few projects being worked on but none have been put into a
release.

Thanks,
Jake

>
>
> Thanks,
>
> Pik Tang
>

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

* Re: Branch deletion question / possible bug?
  2018-04-28  7:44 ` Jacob Keller
@ 2018-04-28 10:30   ` Philip Oakley
  2018-04-28 12:43     ` Johannes Schindelin
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Oakley @ 2018-04-28 10:30 UTC (permalink / raw)
  To: Jacob Keller, Tang (US), Pik S; +Cc: Git List

From: "Jacob Keller" <jacob.keller@gmail.com>
> On Fri, Apr 27, 2018 at 5:29 PM, Tang (US), Pik S <Pik.S.Tang@boeing.com>
> wrote:
>> Hi,
>>
>> I discovered that I was able to delete the feature branch I was in, due
>> to some fat fingering on my part and case insensitivity.  I never
>> realized this could be done before.  A quick google search did not give
>> me a whole lot to work with...
>>
>> Steps to reproduce:
>> 1. Create a feature branch, "editCss"
>> 2. git checkout master
>> 3. git checkout editCSS
>> 4. git checkout editCss
>> 5. git branch -d editCSS
>>
>
> Are you running on a case-insensitive file system? What version of
> git? I thought I recalled seeing commits to help avoid creating
> branches of the same name with separate case when we know we're on a
> file system which is case-insensitive..
>
>> Normally, it should have been impossible for a user to delete the branch
>> they're on.  And the deletion left me in a weird state that took a while
>> to dig out of.
>>
>> I know this was a user error, but I was also wondering if this was a bug.
>
> If we have not yet done this, I think we should. Long term this would
> be fixed by using a separate format to store refs than the filesystem,
> which has a few projects being worked on but none have been put into a
> release.

Yes, this is an on-going problem on Windows and other case insentive
systems. At the moment the branch name becomes embedded as a file name, so
when Git requests details of a branch from the filesystem, it can get a case
insensitive equivalent. Meanwhile, internally Git is checking for equality
in a case sensitive [Linux] way with obvious consequences such as this - The
most obvious being when there is no "*" current branch marker in the branch
status list.

It's a bit tricky to fix (internally the name and the path are passed down
different call chains), and depends on how one expects the case
insensitivity to work - the kicker is when someone does an edit of the name
via the file system and expects Git to cope (i.e. devs knowing, or think
they know, too much detail ;-).

The refs can also get packed, so the "bad spelling" gets baked in.
Ultimately it probably means that GfW and other systems will need  a case
sensitivity check when opening paths...

Philip
>
> Thanks,
> Jake
>
>>
>>
>> Thanks,
>>
>> Pik Tang
>>
>


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

* Re: Branch deletion question / possible bug?
  2018-04-28 10:30   ` Philip Oakley
@ 2018-04-28 12:43     ` Johannes Schindelin
  2018-04-30 19:54       ` Tang (US), Pik S
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2018-04-28 12:43 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Jacob Keller, Tang (US), Pik S, Git List

Hi,

On Sat, 28 Apr 2018, Philip Oakley wrote:

> From: "Jacob Keller" <jacob.keller@gmail.com>
> > On Fri, Apr 27, 2018 at 5:29 PM, Tang (US), Pik S <Pik.S.Tang@boeing.com>
> > wrote:
> > > Hi,
> > >
> > > I discovered that I was able to delete the feature branch I was in, due
> > > to some fat fingering on my part and case insensitivity.  I never
> > > realized this could be done before.  A quick google search did not give
> > > me a whole lot to work with...
> > >
> > > Steps to reproduce:
> > > 1. Create a feature branch, "editCss"
> > > 2. git checkout master
> > > 3. git checkout editCSS
> > > 4. git checkout editCss
> > > 5. git branch -d editCSS
> > >
> >
> > Are you running on a case-insensitive file system? What version of
> > git? I thought I recalled seeing commits to help avoid creating
> > branches of the same name with separate case when we know we're on a
> > file system which is case-insensitive..
> >
> > > Normally, it should have been impossible for a user to delete the branch
> > > they're on.  And the deletion left me in a weird state that took a while
> > > to dig out of.
> > >
> > > I know this was a user error, but I was also wondering if this was a bug.
> >
> > If we have not yet done this, I think we should. Long term this would
> > be fixed by using a separate format to store refs than the filesystem,
> > which has a few projects being worked on but none have been put into a
> > release.
> 
> Yes, this is an on-going problem on Windows and other case insentive
> systems. At the moment the branch name becomes embedded as a file name, so
> when Git requests details of a branch from the filesystem, it can get a case
> insensitive equivalent. Meanwhile, internally Git is checking for equality
> in a case sensitive [Linux] way with obvious consequences such as this - The
> most obvious being when there is no "*" current branch marker in the branch
> status list.
> 
> It's a bit tricky to fix (internally the name and the path are passed down
> different call chains), and depends on how one expects the case
> insensitivity to work - the kicker is when someone does an edit of the name
> via the file system and expects Git to cope (i.e. devs knowing, or think
> they know, too much detail ;-).
> 
> The refs can also get packed, so the "bad spelling" gets baked in.
> Ultimately it probably means that GfW and other systems will need  a case
> sensitivity check when opening paths...

FWIW I outlined what I think is the best route to fix this for good:

https://github.com/git-for-windows/git/issues/1623#issuecomment-380085257

Essentially, I think we should teach Git the trick to check the spelling
before calling lstat() in refs/files-backend.c.

To check the spelling, we would need an API to get the on-disk
representation of a given path. On Windows, I know this call. On Linux,
apparently canonicalize_file_name() might do the job, but that is a GNU
libc extension, and won't help us on macOS.

Any ideas?

Ciao,
Dscho

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

* RE: Branch deletion question / possible bug?
  2018-04-28 12:43     ` Johannes Schindelin
@ 2018-04-30 19:54       ` Tang (US), Pik S
  0 siblings, 0 replies; 5+ messages in thread
From: Tang (US), Pik S @ 2018-04-30 19:54 UTC (permalink / raw)
  To: Johannes Schindelin, Philip Oakley; +Cc: Jacob Keller, Git List

Hello,

Thank you for all your replies.  I am on a case insensitive system (Windows 10) running git version 2.14.1.windows.1.  

While I can't comment on what the fix would be, it has been enlightening to learn a bit more about what's under the cover of git.  

TIL :)
Pik

-----Original Message-----
From: Johannes Schindelin [mailto:Johannes.Schindelin@gmx.de] 
Sent: Saturday, April 28, 2018 5:44 AM
To: Philip Oakley <philipoakley@iee.org>
Cc: Jacob Keller <jacob.keller@gmail.com>; Tang (US), Pik S <Pik.S.Tang@boeing.com>; Git List <git@vger.kernel.org>
Subject: Re: Branch deletion question / possible bug?

Hi,

On Sat, 28 Apr 2018, Philip Oakley wrote:

> From: "Jacob Keller" <jacob.keller@gmail.com>
> > On Fri, Apr 27, 2018 at 5:29 PM, Tang (US), Pik S 
> > <Pik.S.Tang@boeing.com>
> > wrote:
> > > Hi,
> > >
> > > I discovered that I was able to delete the feature branch I was 
> > > in, due to some fat fingering on my part and case insensitivity.  
> > > I never realized this could be done before.  A quick google search 
> > > did not give me a whole lot to work with...
> > >
> > > Steps to reproduce:
> > > 1. Create a feature branch, "editCss"
> > > 2. git checkout master
> > > 3. git checkout editCSS
> > > 4. git checkout editCss
> > > 5. git branch -d editCSS
> > >
> >
> > Are you running on a case-insensitive file system? What version of 
> > git? I thought I recalled seeing commits to help avoid creating 
> > branches of the same name with separate case when we know we're on a 
> > file system which is case-insensitive..
> >
> > > Normally, it should have been impossible for a user to delete the 
> > > branch they're on.  And the deletion left me in a weird state that 
> > > took a while to dig out of.
> > >
> > > I know this was a user error, but I was also wondering if this was a bug.
> >
> > If we have not yet done this, I think we should. Long term this 
> > would be fixed by using a separate format to store refs than the 
> > filesystem, which has a few projects being worked on but none have 
> > been put into a release.
> 
> Yes, this is an on-going problem on Windows and other case insentive 
> systems. At the moment the branch name becomes embedded as a file 
> name, so when Git requests details of a branch from the filesystem, it 
> can get a case insensitive equivalent. Meanwhile, internally Git is 
> checking for equality in a case sensitive [Linux] way with obvious 
> consequences such as this - The most obvious being when there is no 
> "*" current branch marker in the branch status list.
> 
> It's a bit tricky to fix (internally the name and the path are passed 
> down different call chains), and depends on how one expects the case 
> insensitivity to work - the kicker is when someone does an edit of the 
> name via the file system and expects Git to cope (i.e. devs knowing, 
> or think they know, too much detail ;-).
> 
> The refs can also get packed, so the "bad spelling" gets baked in.
> Ultimately it probably means that GfW and other systems will need  a 
> case sensitivity check when opening paths...

FWIW I outlined what I think is the best route to fix this for good:

https://github.com/git-for-windows/git/issues/1623#issuecomment-380085257

Essentially, I think we should teach Git the trick to check the spelling before calling lstat() in refs/files-backend.c.

To check the spelling, we would need an API to get the on-disk representation of a given path. On Windows, I know this call. On Linux, apparently canonicalize_file_name() might do the job, but that is a GNU libc extension, and won't help us on macOS.

Any ideas?

Ciao,
Dscho



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

end of thread, other threads:[~2018-04-30 19:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-28  0:29 Branch deletion question / possible bug? Tang (US), Pik S
2018-04-28  7:44 ` Jacob Keller
2018-04-28 10:30   ` Philip Oakley
2018-04-28 12:43     ` Johannes Schindelin
2018-04-30 19:54       ` Tang (US), Pik S

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.