t7527: test Unicode NFC/NFD handling on MacOS

Confirm that the daemon reports events using the on-disk
spelling for Unicode NFC/NFD characters.  On APFS we still
have Unicode aliasing, so we cannot create two files that
only differ by NFC/NFD, but the on-disk format preserves
the spelling used to create the file.  On HFS+ we also
have aliasing, but the path is always stored on disk in
NFD.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff Hostetler 2022-05-26 21:47:22 +00:00 committed by Junio C Hamano
parent 00991e1013
commit eb299010ee

View file

@ -868,4 +868,59 @@ test_expect_success CASE_INSENSITIVE_FS 'case insensitive+preserving' '
egrep "^event: abc/def/xyz$" ./insensitive.trace
'
# The variable "unicode_debug" is defined in the following library
# script to dump information about how the (OS, FS) handles Unicode
# composition. Uncomment the following line if you want to enable it.
#
# unicode_debug=true
. "$TEST_DIRECTORY/lib-unicode-nfc-nfd.sh"
# See if the OS or filesystem does NFC/NFD aliasing/munging.
#
# The daemon should err on the side of caution and send BOTH the
# NFC and NFD forms. It does not know the original spelling of
# the pathname (how the user thinks it should be spelled), so
# emit both and let the client decide (when necessary). This is
# similar to "core.precomposeUnicode".
#
test_expect_success !UNICODE_COMPOSITION_SENSITIVE 'Unicode nfc/nfd' '
test_when_finished "stop_daemon_delete_repo test_unicode" &&
git init test_unicode &&
start_daemon -C test_unicode --tf "$PWD/unicode.trace" &&
# Create a directory using an NFC spelling.
#
mkdir test_unicode/nfc &&
mkdir test_unicode/nfc/c_${utf8_nfc} &&
# Create a directory using an NFD spelling.
#
mkdir test_unicode/nfd &&
mkdir test_unicode/nfd/d_${utf8_nfd} &&
git -C test_unicode fsmonitor--daemon stop &&
if test_have_prereq UNICODE_NFC_PRESERVED
then
# We should have seen NFC event from OS.
# We should not have synthesized an NFD event.
egrep "^event: nfc/c_${utf8_nfc}/?$" ./unicode.trace &&
egrep -v "^event: nfc/c_${utf8_nfd}/?$" ./unicode.trace
else
# We should have seen NFD event from OS.
# We should have synthesized an NFC event.
egrep "^event: nfc/c_${utf8_nfd}/?$" ./unicode.trace &&
egrep "^event: nfc/c_${utf8_nfc}/?$" ./unicode.trace
fi &&
# We assume UNICODE_NFD_PRESERVED.
# We should have seen explicit NFD from OS.
# We should have synthesized an NFC event.
egrep "^event: nfd/d_${utf8_nfd}/?$" ./unicode.trace &&
egrep "^event: nfd/d_${utf8_nfc}/?$" ./unicode.trace
'
test_done