git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* folder naming bug?
@ 2015-02-03  1:56 Kevin Coleman
  2015-02-03  4:37 ` Bryan Turner
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Coleman @ 2015-02-03  1:56 UTC (permalink / raw)
  To: git

git isn’t tracking folder renames when the case of the letters change, but it will track it if the folder changes names.  Is this intentional?

Here is an example:

08:51:26 ~/test $ git init
Initialized empty Git repository in /Users/kcoleman/test/.git/
08:51:29 ~/test (master #) $ mkdir main
08:51:44 ~/test (master #) $ cd main
08:51:46 ~/test/main (master #) $ touch readme.md
08:51:50 ~/test/main (master #) $ ls
readme.md
08:51:53 ~/test/main (master #) $ cd ..
08:51:54 ~/test (master #) $ git add .
08:51:59 ~/test (master #) $ git commit -m "one"
[master (root-commit) b0fddf6] one
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 main/readme.md
08:52:04 ~/test (master) $ cd main
08:52:14 ~/test/main (master) $ cd ..
08:52:27 ~/test (master) $ mv main Main
08:53:51 ~/test (master) $ git status
On branch master
nothing to commit, working directory clean
08:53:53 ~/test (master) $ ls
Main
08:54:02 ~/test (master) $ mv Main MainA
08:55:44 ~/test (master *) $ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	deleted:    main/readme.md

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	MainA/

no changes added to commit (use "git add" and/or "git commit -a")
08:55:45 ~/test (master *) $

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

* Re: folder naming bug?
  2015-02-03  1:56 folder naming bug? Kevin Coleman
@ 2015-02-03  4:37 ` Bryan Turner
  2015-02-03  4:52   ` Kevin Coleman
  0 siblings, 1 reply; 7+ messages in thread
From: Bryan Turner @ 2015-02-03  4:37 UTC (permalink / raw)
  To: Kevin Coleman; +Cc: Git Users

Are you, by any chance, on MacOS? HFS+ by default is
case-insensitive-but-case-preserving, and Git on MacOS by default runs
with core.ignorecase = true as a result.

If you set that to false does it change the behavior?

Hope this helps,
Bryan Turner

On Tue, Feb 3, 2015 at 12:56 PM, Kevin Coleman
<kevin.coleman@sparkstart.io> wrote:
> git isn’t tracking folder renames when the case of the letters change, but it will track it if the folder changes names.  Is this intentional?
>
> Here is an example:
>
> 08:51:26 ~/test $ git init
> Initialized empty Git repository in /Users/kcoleman/test/.git/
> 08:51:29 ~/test (master #) $ mkdir main
> 08:51:44 ~/test (master #) $ cd main
> 08:51:46 ~/test/main (master #) $ touch readme.md
> 08:51:50 ~/test/main (master #) $ ls
> readme.md
> 08:51:53 ~/test/main (master #) $ cd ..
> 08:51:54 ~/test (master #) $ git add .
> 08:51:59 ~/test (master #) $ git commit -m "one"
> [master (root-commit) b0fddf6] one
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 main/readme.md
> 08:52:04 ~/test (master) $ cd main
> 08:52:14 ~/test/main (master) $ cd ..
> 08:52:27 ~/test (master) $ mv main Main
> 08:53:51 ~/test (master) $ git status
> On branch master
> nothing to commit, working directory clean
> 08:53:53 ~/test (master) $ ls
> Main
> 08:54:02 ~/test (master) $ mv Main MainA
> 08:55:44 ~/test (master *) $ git status
> On branch master
> Changes not staged for commit:
>   (use "git add/rm <file>..." to update what will be committed)
>   (use "git checkout -- <file>..." to discard changes in working directory)
>
>         deleted:    main/readme.md
>
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
>
>         MainA/
>
> no changes added to commit (use "git add" and/or "git commit -a")
> 08:55:45 ~/test (master *) $--
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: folder naming bug?
  2015-02-03  4:37 ` Bryan Turner
@ 2015-02-03  4:52   ` Kevin Coleman
  2015-02-03  5:23     ` Jeff King
  2015-02-03  8:34     ` Torsten Bögershausen
  0 siblings, 2 replies; 7+ messages in thread
From: Kevin Coleman @ 2015-02-03  4:52 UTC (permalink / raw)
  To: Bryan Turner; +Cc: Git Users

Sorry for sending x2.  I got a bounce notification the first time.

====
Yes, I am on a Mac.  I just tried that, but I don’t think that completely fixed it.  As you can see it tracks “foo/bar.md” and then it tracks “Foo/bar.md”.  It still tracks both “foo” and “Foo” even tho only “Foo” exists in my dir after the rename.

I create a public repo on github with this repo https://github.com/KevinColemanInc/test

I am running git version 2.2.2.

11:41:57 ~/test $ git init
Initialized empty Git repository in /Users/kcoleman/test/.git/
11:42:03 ~/test (master #) $ git config core.ignorecase false
11:42:06 ~/test (master #) $ mkdir foo
11:42:13 ~/test (master #) $ cd foo
11:42:26 ~/test/foo (master #) $ touch bar.md
11:42:30 ~/test/foo (master #) $ cd ..
11:42:32 ~/test (master #) $ git add .
11:42:35 ~/test (master #) $ git commit -m "first"
[master (root-commit) 6125a1d] first
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo/bar.md
11:42:39 ~/test (master) $ mv foo Foo
11:42:44 ~/test (master) $ ls
Foo
11:42:46 ~/test (master) $ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	Foo/

nothing added to commit but untracked files present (use "git add" to track)
11:42:48 ~/test (master) $ git add .
11:43:18 ~/test (master +) $ git commit -m "second"
[master f78d025] second
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 Foo/bar.md

-Kevin Coleman

> On Feb 2, 2015, at 11:37 PM, Bryan Turner <bturner@atlassian.com> wrote:
> 
> Are you, by any chance, on MacOS? HFS+ by default is
> case-insensitive-but-case-preserving, and Git on MacOS by default runs
> with core.ignorecase = true as a result.
> 
> If you set that to false does it change the behavior?
> 
> Hope this helps,
> Bryan Turner
> 
> On Tue, Feb 3, 2015 at 12:56 PM, Kevin Coleman
> <kevin.coleman@sparkstart.io> wrote:
>> git isn’t tracking folder renames when the case of the letters change, but it will track it if the folder changes names.  Is this intentional?
>> 
>> Here is an example:
>> 
>> 08:51:26 ~/test $ git init
>> Initialized empty Git repository in /Users/kcoleman/test/.git/
>> 08:51:29 ~/test (master #) $ mkdir main
>> 08:51:44 ~/test (master #) $ cd main
>> 08:51:46 ~/test/main (master #) $ touch readme.md
>> 08:51:50 ~/test/main (master #) $ ls
>> readme.md
>> 08:51:53 ~/test/main (master #) $ cd ..
>> 08:51:54 ~/test (master #) $ git add .
>> 08:51:59 ~/test (master #) $ git commit -m "one"
>> [master (root-commit) b0fddf6] one
>> 1 file changed, 0 insertions(+), 0 deletions(-)
>> create mode 100644 main/readme.md
>> 08:52:04 ~/test (master) $ cd main
>> 08:52:14 ~/test/main (master) $ cd ..
>> 08:52:27 ~/test (master) $ mv main Main
>> 08:53:51 ~/test (master) $ git status
>> On branch master
>> nothing to commit, working directory clean
>> 08:53:53 ~/test (master) $ ls
>> Main
>> 08:54:02 ~/test (master) $ mv Main MainA
>> 08:55:44 ~/test (master *) $ git status
>> On branch master
>> Changes not staged for commit:
>>  (use "git add/rm <file>..." to update what will be committed)
>>  (use "git checkout -- <file>..." to discard changes in working directory)
>> 
>>        deleted:    main/readme.md
>> 
>> Untracked files:
>>  (use "git add <file>..." to include in what will be committed)
>> 
>>        MainA/
>> 
>> no changes added to commit (use "git add" and/or "git commit -a")
>> 08:55:45 ~/test (master *) $--
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: folder naming bug?
  2015-02-03  4:52   ` Kevin Coleman
@ 2015-02-03  5:23     ` Jeff King
  2015-02-03  6:23       ` Kevin Coleman
  2015-02-03  8:34     ` Torsten Bögershausen
  1 sibling, 1 reply; 7+ messages in thread
From: Jeff King @ 2015-02-03  5:23 UTC (permalink / raw)
  To: Kevin Coleman; +Cc: Bryan Turner, Git Users

On Mon, Feb 02, 2015 at 11:52:21PM -0500, Kevin Coleman wrote:

> Yes, I am on a Mac.  I just tried that, but I don’t think that
> completely fixed it.  As you can see it tracks “foo/bar.md” and then
> it tracks “Foo/bar.md”.  It still tracks both “foo” and “Foo” even tho
> only “Foo” exists in my dir after the rename.

Yes, because your filesystem _is_ case insensitive, but now you have
told git that it is not. In your example:

> 11:41:57 ~/test $ git init
> Initialized empty Git repository in /Users/kcoleman/test/.git/
> 11:42:03 ~/test (master #) $ git config core.ignorecase false
> 11:42:06 ~/test (master #) $ mkdir foo
> 11:42:13 ~/test (master #) $ cd foo
> 11:42:26 ~/test/foo (master #) $ touch bar.md
> 11:42:30 ~/test/foo (master #) $ cd ..
> 11:42:32 ~/test (master #) $ git add .

Now git has "foo" (lowercase) in the index. And that's what your
filesystem has, too.

> 11:42:35 ~/test (master #) $ git commit -m "first"
> [master (root-commit) 6125a1d] first
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 foo/bar.md
> 11:42:39 ~/test (master) $ mv foo Foo
> 11:42:44 ~/test (master) $ ls
> Foo

Now we still have "foo" in the index, but "Foo" in the filesystem.

> 11:42:46 ~/test (master) $ git status
> On branch master
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
> 
> 	Foo/

When git asks the filesystem lstat("foo") to find out if we still have
it, the filesystem returns the entry for "Foo" (because it is
case-insensitive).

But when git asks the filesystem to iterate over all of the files, so it
can check which ones are not tracked, it will get "Foo", which of course
is not in the index.

So you do not see a deletion of "foo", but you do see "Foo" as
untracked.

> 11:42:48 ~/test (master) $ git add .
> 11:43:18 ~/test (master +) $ git commit -m "second"
> [master f78d025] second
>  1 file changed, 0 insertions(+), 0 deletions(-)
>  create mode 100644 Foo/bar.md

And this tells git to look through the filesystem for untracked files
and add them to the index. So it adds "Foo".

Now that you have both "foo" and "Foo" in the index, but the filesystem
treats them the same, you can create more mayhem. If you were to update
one entry but not the other (e.g., by writing to bar.md before doing the
second commit), then git would be perpetually confused. _One_ of the
files would always look like needed to be updated, because the
filesystem cannot represent the situation that is in the index.

And that is why git sets core.ignorecase in the first place. :)

As to your original problem:

> >> git isn’t tracking folder renames when the case of the letters
> >> change, but it will track it if the folder changes names.  Is this
> >> intentional?

Yes, this is intentional. Your filesystem treats them as the same file,
so git has to, as well.

If your goal is to change the case that git records, then you should be
able to do it with "git mv". But git will never pick up a case change
that you made separately in the filesystem, because it's
indistinguishable from the filesystem simply picking a different case to
store the file.

And that does happen. For instance, if you switch between two branches
with "Foo" and "foo", most case-preserving filesystems will leave you
with whichever version you had first (i.e., git asks the filesystem to
open "foo", and the filesystem says "ah, I already have Foo; that must
have been what you meant").

-Peff

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

* Re: folder naming bug?
  2015-02-03  5:23     ` Jeff King
@ 2015-02-03  6:23       ` Kevin Coleman
  2015-02-03  8:40         ` Torsten Bögershausen
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Coleman @ 2015-02-03  6:23 UTC (permalink / raw)
  To: Jeff King; +Cc: Bryan Turner, Git Users

Awesome reply! That makes sense.  So basically if I accidentally capitalize a folder name and commit it, I need to be very careful when I correct it.  Definitely ran into this problem with my repo and ‘lost’ a few commits before I noticed something was off.

-Kevin Coleman

> On Feb 3, 2015, at 12:23 AM, Jeff King <peff@peff.net> wrote:
> 
> On Mon, Feb 02, 2015 at 11:52:21PM -0500, Kevin Coleman wrote:
> 
>> Yes, I am on a Mac.  I just tried that, but I don’t think that
>> completely fixed it.  As you can see it tracks “foo/bar.md” and then
>> it tracks “Foo/bar.md”.  It still tracks both “foo” and “Foo” even tho
>> only “Foo” exists in my dir after the rename.
> 
> Yes, because your filesystem _is_ case insensitive, but now you have
> told git that it is not. In your example:
> 
>> 11:41:57 ~/test $ git init
>> Initialized empty Git repository in /Users/kcoleman/test/.git/
>> 11:42:03 ~/test (master #) $ git config core.ignorecase false
>> 11:42:06 ~/test (master #) $ mkdir foo
>> 11:42:13 ~/test (master #) $ cd foo
>> 11:42:26 ~/test/foo (master #) $ touch bar.md
>> 11:42:30 ~/test/foo (master #) $ cd ..
>> 11:42:32 ~/test (master #) $ git add .
> 
> Now git has "foo" (lowercase) in the index. And that's what your
> filesystem has, too.
> 
>> 11:42:35 ~/test (master #) $ git commit -m "first"
>> [master (root-commit) 6125a1d] first
>> 1 file changed, 0 insertions(+), 0 deletions(-)
>> create mode 100644 foo/bar.md
>> 11:42:39 ~/test (master) $ mv foo Foo
>> 11:42:44 ~/test (master) $ ls
>> Foo
> 
> Now we still have "foo" in the index, but "Foo" in the filesystem.
> 
>> 11:42:46 ~/test (master) $ git status
>> On branch master
>> Untracked files:
>>  (use "git add <file>..." to include in what will be committed)
>> 
>> 	Foo/
> 
> When git asks the filesystem lstat("foo") to find out if we still have
> it, the filesystem returns the entry for "Foo" (because it is
> case-insensitive).
> 
> But when git asks the filesystem to iterate over all of the files, so it
> can check which ones are not tracked, it will get "Foo", which of course
> is not in the index.
> 
> So you do not see a deletion of "foo", but you do see "Foo" as
> untracked.
> 
>> 11:42:48 ~/test (master) $ git add .
>> 11:43:18 ~/test (master +) $ git commit -m "second"
>> [master f78d025] second
>> 1 file changed, 0 insertions(+), 0 deletions(-)
>> create mode 100644 Foo/bar.md
> 
> And this tells git to look through the filesystem for untracked files
> and add them to the index. So it adds "Foo".
> 
> Now that you have both "foo" and "Foo" in the index, but the filesystem
> treats them the same, you can create more mayhem. If you were to update
> one entry but not the other (e.g., by writing to bar.md before doing the
> second commit), then git would be perpetually confused. _One_ of the
> files would always look like needed to be updated, because the
> filesystem cannot represent the situation that is in the index.
> 
> And that is why git sets core.ignorecase in the first place. :)
> 
> As to your original problem:
> 
>>>> git isn’t tracking folder renames when the case of the letters
>>>> change, but it will track it if the folder changes names.  Is this
>>>> intentional?
> 
> Yes, this is intentional. Your filesystem treats them as the same file,
> so git has to, as well.
> 
> If your goal is to change the case that git records, then you should be
> able to do it with "git mv". But git will never pick up a case change
> that you made separately in the filesystem, because it's
> indistinguishable from the filesystem simply picking a different case to
> store the file.
> 
> And that does happen. For instance, if you switch between two branches
> with "Foo" and "foo", most case-preserving filesystems will leave you
> with whichever version you had first (i.e., git asks the filesystem to
> open "foo", and the filesystem says "ah, I already have Foo; that must
> have been what you meant").
> 
> -Peff

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

* Re: folder naming bug?
  2015-02-03  4:52   ` Kevin Coleman
  2015-02-03  5:23     ` Jeff King
@ 2015-02-03  8:34     ` Torsten Bögershausen
  1 sibling, 0 replies; 7+ messages in thread
From: Torsten Bögershausen @ 2015-02-03  8:34 UTC (permalink / raw)
  To: Kevin Coleman, Bryan Turner; +Cc: Git Users


On 02/03/2015 05:52 AM, Kevin Coleman wrote:
> ====
> Yes, I am on a Mac.  I just tried that, but I don’t think that completely fixed it.  As you can see it tracks “foo/bar.md” and then it tracks “Foo/bar.md”.  It still tracks both “foo” and “Foo” even tho only “Foo” exists in my dir after the rename.
You asked Git to track Foo/bar.md and the file system says "yes, it's here"
When you rename Foo/ into foo/, the file system still says "Foo/bar.md" 
is here.
You need to tell git about the rename :
git mv Foo/bar.md foo/bar.md

Why does anybody think that setting "core.ignorecase false" will 
convince the file system
to become case insensitive ?

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

* Re: folder naming bug?
  2015-02-03  6:23       ` Kevin Coleman
@ 2015-02-03  8:40         ` Torsten Bögershausen
  0 siblings, 0 replies; 7+ messages in thread
From: Torsten Bögershausen @ 2015-02-03  8:40 UTC (permalink / raw)
  To: Kevin Coleman, Jeff King; +Cc: Bryan Turner, Git Users

On 02/03/2015 07:23 AM, Kevin Coleman wrote:
> Awesome reply! That makes sense.  So basically if I accidentally capitalize a folder name and commit it, I need to be very careful when I correct it.  Definitely ran into this problem with my repo and ‘lost’ a few commits before I noticed something was off.
>
> -Kevin Coleman
(Please no top-posting)

According to my experience setting core.ignorecase false
may cause the user to loose commits.

Can you reproduce the problem ?
with core.ignorecase false (Which is wrong)
with core.ignorecase true (You shouldn't loose anything)

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

end of thread, other threads:[~2015-02-03  8:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-03  1:56 folder naming bug? Kevin Coleman
2015-02-03  4:37 ` Bryan Turner
2015-02-03  4:52   ` Kevin Coleman
2015-02-03  5:23     ` Jeff King
2015-02-03  6:23       ` Kevin Coleman
2015-02-03  8:40         ` Torsten Bögershausen
2015-02-03  8:34     ` Torsten Bögershausen

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