From 2455406ab1b0e2b0ad9e5273b9aef6c739d5b8fe Mon Sep 17 00:00:00 2001 From: Dmitry Potapov Date: Sun, 11 May 2008 18:16:39 +0200 Subject: [PATCH 1/5] git-init: autodetect core.ignorecase 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 Signed-off-by: Steffen Prohaska Signed-off-by: Junio C Hamano --- builtin-init-db.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builtin-init-db.c b/builtin-init-db.c index a76f5d3474..b061317275 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; From 1c51c7d7d97acb447050a820dc39d242dc29c5df Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sun, 11 May 2008 18:16:40 +0200 Subject: [PATCH 2/5] t0050: Test autodetect core.ignorecase 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 Signed-off-by: Junio C Hamano --- t/t0050-filesystem.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 3fbad77811..66d3647bda 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 && From b4a299d87ca7a1d39c699ee2af28305e57f3b0ae Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sun, 11 May 2008 18:16:41 +0200 Subject: [PATCH 3/5] t0050: Set core.ignorecase case to activate case insensitivity 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 Signed-off-by: Junio C Hamano --- t/t0050-filesystem.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 66d3647bda..399b45df1f 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" && From 8a19aaab6394df2c6138d5b8b1411eb00bfcf442 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sun, 11 May 2008 18:16:42 +0200 Subject: [PATCH 4/5] t0050: Add test for case insensitive add 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 Signed-off-by: Junio C Hamano --- t/t0050-filesystem.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 399b45df1f..0e33c4bdc7 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 && From 0047dd2fd1fc1980913901c5fa098357482c2842 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Thu, 15 May 2008 07:19:54 +0200 Subject: [PATCH 5/5] t0050: Fix merge test on case sensitive file systems On a case sensitive filesystem, "git reset --hard" might refuse to overwrite a file whose name differs only by case, even if core.ignorecase is set. It is not clear which circumstances cause this behavior. This commit simply works around the problem by removing the case changing file before running "git reset --hard". Signed-off-by: Steffen Prohaska Signed-off-by: Junio C Hamano --- t/t0050-filesystem.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 0e33c4bdc7..c5360e23d9 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -72,6 +72,8 @@ $test_case 'rename (case change)' ' $test_case 'merge (case change)' ' + rm -f CamelCase && + rm -f camelcase && git reset --hard initial && git merge topic