Skip to content

Commit

Permalink
Merge branch 'sp/ignorecase'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed May 23, 2008
2 parents e13067a + 0047dd2 commit 6aad47d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
8 changes: 7 additions & 1 deletion builtin-init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) &&
Expand All @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions t/t0050-filesystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 &&
Expand All @@ -32,8 +34,23 @@ 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" '
git config core.ignorecase true &&
touch camelcase &&
git add camelcase &&
git commit -m "initial" &&
Expand All @@ -55,11 +72,23 @@ $test_case 'rename (case change)' '

$test_case 'merge (case change)' '
rm -f CamelCase &&
rm -f camelcase &&
git reset --hard initial &&
git merge topic
'

$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 &&
Expand Down

0 comments on commit 6aad47d

Please sign in to comment.