Skip to content

Commit 6aad47d

Browse files
committed
Merge branch 'sp/ignorecase'
* sp/ignorecase: t0050: Fix merge test on case sensitive file systems t0050: Add test for case insensitive add t0050: Set core.ignorecase case to activate case insensitivity t0050: Test autodetect core.ignorecase git-init: autodetect core.ignorecase
2 parents e13067a + 0047dd2 commit 6aad47d

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

builtin-init-db.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ static int create_default_files(const char *git_dir, const char *template_path)
255255
git_config_set("core.worktree", work_tree);
256256
}
257257

258-
/* Check if symlink is supported in the work tree */
259258
if (!reinit) {
259+
/* Check if symlink is supported in the work tree */
260260
path[len] = 0;
261261
strcpy(path + len, "tXXXXXX");
262262
if (!close(xmkstemp(path)) &&
@@ -267,6 +267,12 @@ static int create_default_files(const char *git_dir, const char *template_path)
267267
unlink(path); /* good */
268268
else
269269
git_config_set("core.symlinks", "false");
270+
271+
/* Check if the filesystem is case-insensitive */
272+
path[len] = 0;
273+
strcpy(path + len, "CoNfIg");
274+
if (!access(path, F_OK))
275+
git_config_set("core.ignorecase", "true");
270276
}
271277

272278
return reinit;

t/t0050-filesystem.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test_description='Various filesystem issues'
77
auml=`printf '\xc3\xa4'`
88
aumlcdiar=`printf '\x61\xcc\x88'`
99

10+
case_insensitive=
1011
test_expect_success 'see if we expect ' '
1112
1213
test_case=test_expect_success
@@ -17,6 +18,7 @@ test_expect_success 'see if we expect ' '
1718
if test "$(cat junk/CamelCase)" != good
1819
then
1920
test_case=test_expect_failure
21+
case_insensitive=t
2022
say "will test on a case insensitive filesystem"
2123
fi &&
2224
rm -fr junk &&
@@ -32,8 +34,23 @@ test_expect_success 'see if we expect ' '
3234
rm -fr junk
3335
'
3436

37+
if test "$case_insensitive"
38+
then
39+
test_expect_success "detection of case insensitive filesystem during repo init" '
40+
41+
test $(git config --bool core.ignorecase) = true
42+
'
43+
else
44+
test_expect_success "detection of case insensitive filesystem during repo init" '
45+
46+
! git config --bool core.ignorecase >/dev/null ||
47+
test $(git config --bool core.ignorecase) = false
48+
'
49+
fi
50+
3551
test_expect_success "setup case tests" '
3652
53+
git config core.ignorecase true &&
3754
touch camelcase &&
3855
git add camelcase &&
3956
git commit -m "initial" &&
@@ -55,11 +72,23 @@ $test_case 'rename (case change)' '
5572

5673
$test_case 'merge (case change)' '
5774
75+
rm -f CamelCase &&
76+
rm -f camelcase &&
5877
git reset --hard initial &&
5978
git merge topic
6079
6180
'
6281

82+
$test_case 'add (with different case)' '
83+
84+
git reset --hard initial &&
85+
rm camelcase &&
86+
echo 1 >CamelCase &&
87+
git add CamelCase &&
88+
test $(git-ls-files | grep -i camelcase | wc -l) = 1
89+
90+
'
91+
6392
test_expect_success "setup unicode normalization tests" '
6493
6594
test_create_repo unicode &&

0 commit comments

Comments
 (0)