From: Dmitry Potapov <dpotapov@gmail.com>
We already detect if symbolic links are supported by the filesystem.
This patch adds autodetect for case-insensitive filesystems, such
as VFAT and others.
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
builtin-init-db.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 2854868..3721bd2 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -255,8 +255,8 @@ static int create_default_files(const char *git_dir, const char *template_path)
git_config_set("core.worktree", work_tree);
}
- /* Check if symlink is supported in the work tree */
if (!reinit) {
+ /* Check if symlink is supported in the work tree */
path[len] = 0;
strcpy(path + len, "tXXXXXX");
if (!close(xmkstemp(path)) &&
@@ -267,6 +267,12 @@ static int create_default_files(const char *git_dir, const char *template_path)
unlink(path); /* good */
else
git_config_set("core.symlinks", "false");
+
+ /* Check if the filesystem is case-insensitive */
+ path[len] = 0;
+ strcpy(path + len, "CoNfIg");
+ if (!access(path, F_OK))
+ git_config_set("core.ignorecase", "true");
}
return reinit;
--
1.5.5.1.313.g9decb
--
Verify if core.ignorecase is automatically set to 'true' during repository initialization if the file system is case insensitive, and unset or 'false' otherwise. Signed-off-by: Steffen Prohaska <prohaska@zib.de> --- t/t0050-filesystem.sh | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 3fbad77..66d3647 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -7,6 +7,7 @@ test_description='Various filesystem issues' auml=`printf '\xc3\xa4'` aumlcdiar=`printf '\x61\xcc\x88'` +case_insensitive= test_expect_success 'see if we expect ' ' test_case=test_expect_success @@ -17,6 +18,7 @@ test_expect_success 'see if we expect ' ' if test "$(cat junk/CamelCase)" != good then test_case=test_expect_failure + case_insensitive=t say "will test on a case insensitive filesystem" fi && rm -fr junk && @@ -32,6 +34,20 @@ test_expect_success 'see if we expect ' ' rm -fr junk ' +if test "$case_insensitive" +then +test_expect_success "detection of case insensitive filesystem during repo init" ' + + test $(git config --bool core.ignorecase) = true +' +else +test_expect_success "detection of case insensitive filesystem during repo init" ' + + ! git config --bool core.ignorecase >/dev/null || + test $(git config --bool core.ignorecase) = false +' +fi + test_expect_success "setup case tests" ' touch camelcase && -- 1.5.5.1.313.g9decb --
Case insensitive file handling is only active when core.ignorecase = true. Hence, we need to set it to give the tests in t0050 a chance to succeed. Setting core.ignorecase explicitly allows to test some aspects of case handling even on case sensitive file systems. Signed-off-by: Steffen Prohaska <prohaska@zib.de> --- t/t0050-filesystem.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 66d3647..399b45d 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -50,6 +50,7 @@ fi test_expect_success "setup case tests" ' + git config core.ignorecase true && touch camelcase && git add camelcase && git commit -m "initial" && -- 1.5.5.1.313.g9decb --
Add should recognize if a file is added with a different case and add the file using its original name. Signed-off-by: Steffen Prohaska <prohaska@zib.de> --- t/t0050-filesystem.sh | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 399b45d..0e33c4b 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -77,6 +77,16 @@ $test_case 'merge (case change)' ' ' +$test_case 'add (with different case)' ' + + git reset --hard initial && + rm camelcase && + echo 1 >CamelCase && + git add CamelCase && + test $(git-ls-files | grep -i camelcase | wc -l) = 1 + +' + test_expect_success "setup unicode normalization tests" ' test_create_repo unicode && -- 1.5.5.1.313.g9decb --
The patch series looks fine to me, but I just wanted to underline the use of that "*some*aspects*" part. On a filesystem that is case sensitive, doing "core.ignorecase = true" doesn't magically make git act as if the filesystem was insensitive to case. In particular, since the filesystem very much can contain two different versions of a filename in different case, git will actually notice that, and notice that "CamelCase" and "camelcase" are not necessarily the same file. To emulate case insensitivity on filesyststems that are actually sensitive, we could do some tests that do things like echo Hello > CamelCase ln CamelCase camelcase and now git will see something that is *closer* to a real case-insensitive filesystem: two names that resolve to the same stat information. It's still obviously not identical (because "readdir()" will get two entries), and as such a test that succeeds in a true case-insensitive environment will not necessarily work in the above fake kind of situation, but at least you can test some cases. Renaming the same file to a case that is different is also a worthwhile thing to try to "emulate" case insensitivity. Linus --
[ I forgot the "--compose" switch to "git send-email", so the intro
follows as a reply to PATCH 1/4. ]
This patch series improves initialization of a repository and adds
some tests
for core.ignorecase. It should be applied on top of lt/case-
insensitive.
[PATCH 1/4] git-init: autodetect core.ignorecase
1/4 was proposed some time ago as
http://mid.gmane.org/<20080325104931.GJ25381@dpotapov.dyndns.org>
but did not make it into Junio's next.
[PATCH 2/4] t0050: Test autodetect core.ignorecase
[PATCH 3/4] t0050: Set core.ignorecase case to activate case
insensitivity
[PATCH 4/4] t0050: Add test for case insensitive add
2-4/4 add some tests.
Steffen
--
| Jesse Barnes | Re: [stable] [BUG][PATCH] cpqphp: fix kernel NULL pointer dereference |
| Greg KH | [003/136] p54usb: add Zcomax XG-705A usbid |
| Magnus Damm | [PATCH 03/07] ARM: Use shared GIC entry macros on Realview |
| Oliver Neukum | Re: [Bug #13682] The webcam stopped working when upgrading from 2.6.29 to 2.6.30 |
| Martin Schwidefsky | Re: [PATCH] optimized ktime_get[_ts] for GENERIC_TIME=y |
git: | |
| Junio C Hamano | Re: Some advanced index playing |
| Jeff King | Re: confusion over the new branch and merge config |
| Robin Rosenberg | Re: cvs2svn conversion directly to git ready for experimentation |
| Linus Torvalds | git binary size... |
| Ævar Arnfjörð Bjarmason | Re: Challenge with Git-Bash |
| Linux Kernel Mailing List | md: move allocation of ->queue from mddev_find to md_probe |
| Linux Kernel Mailing List | md: raid0: Represent zone->zone_offset in sectors. |
| Linux Kernel Mailing Lis |
