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>
Jeff Hostetler committed
May 26, 2022 at 21:47 UTC
eb299010eee63b5a069d82836efb38969ffd4109
1 file changed
+55
t/t7527-builtin-fsmonitor.sh
+55
@@ -868,4 +868,59 @@ test_expect_success CASE_INSENSITIVE_FS 'case insensitive+preserving' '
868
egrep "^event: abc/def/xyz$" ./insensitive.trace
869
'
870
871
+# The variable "unicode_debug" is defined in the following library
872
+# script to dump information about how the (OS, FS) handles Unicode
873
+# composition. Uncomment the following line if you want to enable it.
874
+#
875
+# unicode_debug=true
876
+
877
+. "$TEST_DIRECTORY/lib-unicode-nfc-nfd.sh"
878
+
879
+# See if the OS or filesystem does NFC/NFD aliasing/munging.
880
+#
881
+# The daemon should err on the side of caution and send BOTH the
882
+# NFC and NFD forms. It does not know the original spelling of
883
+# the pathname (how the user thinks it should be spelled), so
884
+# emit both and let the client decide (when necessary). This is
885
+# similar to "core.precomposeUnicode".
886
+#
887
+test_expect_success !UNICODE_COMPOSITION_SENSITIVE 'Unicode nfc/nfd' '
888
+ test_when_finished "stop_daemon_delete_repo test_unicode" &&
889
+
890
+ git init test_unicode &&
891
+
892
+ start_daemon -C test_unicode --tf "$PWD/unicode.trace" &&
893
+
894
+ # Create a directory using an NFC spelling.
895
+ #
896
+ mkdir test_unicode/nfc &&
897
+ mkdir test_unicode/nfc/c_${utf8_nfc} &&
898
+
899
+ # Create a directory using an NFD spelling.
900
+ #
901
+ mkdir test_unicode/nfd &&
902
+ mkdir test_unicode/nfd/d_${utf8_nfd} &&
903
+
904
+ git -C test_unicode fsmonitor--daemon stop &&
905
+
906
+ if test_have_prereq UNICODE_NFC_PRESERVED
907
+ then
908
+ # We should have seen NFC event from OS.
909
+ # We should not have synthesized an NFD event.
910
+ egrep "^event: nfc/c_${utf8_nfc}/?$" ./unicode.trace &&
911
+ egrep -v "^event: nfc/c_${utf8_nfd}/?$" ./unicode.trace
912
+ else
913
+ # We should have seen NFD event from OS.
914
+ # We should have synthesized an NFC event.
915
+ egrep "^event: nfc/c_${utf8_nfd}/?$" ./unicode.trace &&
916
+ egrep "^event: nfc/c_${utf8_nfc}/?$" ./unicode.trace
917
+ fi &&
918
+
919
+ # We assume UNICODE_NFD_PRESERVED.
920
+ # We should have seen explicit NFD from OS.
921
+ # We should have synthesized an NFC event.
922
+ egrep "^event: nfd/d_${utf8_nfd}/?$" ./unicode.trace &&
923
+ egrep "^event: nfd/d_${utf8_nfc}/?$" ./unicode.trace
924
+'
925
+
926
test_done