voila
voila

Reputation: 1666

Git - folder case sensitive issue

I am trying to bring a already existing codebase in version control system like git.

I am facing a particular issue where codebase contains two folder with same name but different case like 'Form' and 'form'.

Here is the scenario : Suppose, we have three system Linux ( case sensitive file system ) , MAC ( Not case sensitive ) and WINDOWS ( not case sensitive )

Now if someone on LINUX create a folder name FORM having files a.php , b.php , c.php and another folder name form having files a.php , b.php , d.php and pushes it to remote repo

Now when a user on MAC or WINDOWS clone the repo then how will git behave when handling FORM and form coming from remote because MAC and WINDOWS are case insensitive

Upvotes: 34

Views: 27572

Answers (4)

VonC
VonC

Reputation: 1324248

how will git behave when handling FORM and form coming from remote because MAC and WINDOWS are case insensitive

Better, since Git 2.17 (Q2 2018), because Git will keep track of those folders with different case in all instances.

Before, a "git add" files in the same directory, but with spelling the directory path in different cases on case insensitive filesystem, corrupted the name hash data structure and led to unexpected results.

See commit c95525e (08 Feb 2018) by Ben Peart (benpeart).
(Merged by Junio C Hamano -- gitster -- in commit 2ac76d8, 27 Feb 2018)

name-hash: properly fold directory names in adjust_dirname_case()

Correct the pointer arithmetic in adjust_dirname_case() so that it calls find_dir_entry() with the correct string length.

Previously passing in "dir1/foo" would pass a length of 6 instead of the correct 4.
This resulted in find_dir_entry() never finding the entry and so the subsequent memcpy that would fold the name to the version with the correct case never executed.

Upvotes: 2

Jayan
Jayan

Reputation: 18459

You must really fix the file names. It may be useful to use

git config core.ignorecase false

Just in case you want to mix the environment. See more in How do I commit case-sensitive only filename changes in Git?

Upvotes: 46

Adi Levin
Adi Levin

Reputation: 5233

You should rename your folders so that two sibling folders are never identical (with case-insensitive comparison). This will make your code base more portable, and less error-prone, because developers will not confuse one folder with the other.

Upvotes: 5

CodeWizard
CodeWizard

Reputation: 142094

I am facing a particular issue where codebase contains two folder with same name but different case like 'Form' and 'form'.

Git is a unix based code. its is case sensitive so it will allow you to have the same name in different cases, and as you except windows will not be tolerated for this.

There is nothing you can do about it beside renaming your folders.


This issue even raised a security bug in git which allowed you to store folders like:

.GIT
.GIt

http://git-blame.blogspot.com.es/2014/12/git-1856-195-205-214-and-221-and.html

You can commit and checkout to .Git/<anything> (or any permutations of cases .[gG][iI][tT], except .git all in lowercase).

But this will overwrite the corresponding .git/ on case-insensitive file systems (e.g. Windows and Mac OS X). As for now you can do nothing about it and you willneed to have diffrent folders.

Upvotes: 0

Related Questions