This helps cross-platform projects on the case-sensitive filename side of operating systems to use filenames that are nice for the case-insensitive side --- On Fri, May 15, 2009 at 12:52:41PM +0200, Martin Langhoff wrote: > On Thu, May 14, 2009 at 7:59 PM, Heiko Voigt <hvoigt@xxxxxxxxxx> wrote: > > At the moment non-ascii encodings of filenames are not portably converted > > between different filesystems by git. This will most likely change in the > > future but to allow repositories to be portable among different file/operating > > systems this check is enabled by default. > - It'd be a good idea to add to the mix a check for filenames that > are equivalent in case-insensitive FSs. Totally untested. Just to get feedback if someone has ideas how this can be solved more efficiently. I suspect that processing all files will yield an unbearable performance degradation on large projects. Let me know what you think. The wording of the error message is not yet final. templates/hooks--pre-commit.sample | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample index b11ad6a..32d1809 100755 --- a/templates/hooks--pre-commit.sample +++ b/templates/hooks--pre-commit.sample @@ -9,6 +9,10 @@ # If you want to allow non-ascii filenames set this variable to true. allownonascii=$(git config hooks.allownonascii) +# If you want to allow filenames that only differ in case set this +# variable to true. NOTE: This can degrade performance on project with +# lots of files +allowcaseonly=$(git config hooks.allowcaseonly) # Cross platform projects tend to avoid non-ascii filenames; prevent # them from being added to the repository. We exploit the fact that the @@ -32,6 +36,23 @@ then exit 1 fi +# check for names that already exist but only differ in case +# which can be problematic on non-casesensitive filesystems +if [ "$allowcaseonly" != "true" ] && + test -z "$(git ls-files | LC_ALL=C tr -s [A-Z] [a-z] | uniq -d)" +then + echo "Error: Attempt to add file which already exists in different case" + echo + echo "If you know what you are doing you can disable this" + echo "check using:" + echo + echo " git config hooks.allowcaseonly true" + echo + exit 1 +fi + if git-rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD -- 1.6.3.2.203.g9a122 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html