]> git.ipfire.org Git - thirdparty/git.git/commit - utf8.h
utf8: add is_hfs_dotgit() helper
authorJeff King <peff@peff.net>
Mon, 15 Dec 2014 22:56:59 +0000 (17:56 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Dec 2014 19:04:39 +0000 (11:04 -0800)
commit6162a1d323d24fd8cbbb1a6145a91fb849b2568f
treefe77ce47be17b0db00aeca5ad9ec79d1ca034ebc
parent76e86fc6e3523d28e8db00e7b10c33c553d996b8
utf8: add is_hfs_dotgit() helper

We do not allow paths with a ".git" component to be added to
the index, as that would mean repository contents could
overwrite our repository files. However, asking "is this
path the same as .git" is not as simple as strcmp() on some
filesystems.

HFS+'s case-folding does more than just fold uppercase into
lowercase (which we already handle with strcasecmp). It may
also skip past certain "ignored" Unicode code points, so
that (for example) ".gi\u200ct" is mapped ot ".git".

The full list of folds can be found in the tables at:

  https://www.opensource.apple.com/source/xnu/xnu-1504.15.3/bsd/hfs/hfscommon/Unicode/UCStringCompareData.h

Implementing a full "is this path the same as that path"
comparison would require us importing the whole set of
tables.  However, what we want to do is much simpler: we
only care about checking ".git". We know that 'G' is the
only thing that folds to 'g', and so on, so we really only
need to deal with the set of ignored code points, which is
much smaller.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
utf8.c
utf8.h