Skip to main content

Module precompose

Module precompose 

Source
Expand description

macOS HFS+/APFS Unicode path precomposition (core.precomposeunicode).

On Apple filesystems, directory entries are typically stored in NFD while Git wants NFC path names in the index and trees. When core.precomposeunicode is true, Git:

  1. Converts NFD command-line paths to NFC (precompose_string_if_needed)
  2. Converts NFD names from readdir to NFC (precompose_utf8_readdir)

This module mirrors that behavior for Sley. Conversion is gated by a process-wide flag set from the effective repository config (same role as git’s precomposed_unicode cache). The flag is shared across threads so parallel worktree/status workers see the same value as the main thread.

Functions§

activate_precompose_unicode
Activate precomposition from a config bool (or None → disabled).
has_non_ascii
True if s contains any non-ASCII byte (git’s has_non_ascii path check).
has_non_ascii_bytes
True if bytes contains any non-ASCII byte.
precompose_argv_if_needed
Precompose every string in args in place (git’s precompose_argv_prefix).
precompose_bytes_if_needed
Convert UTF-8 bytes from NFD to NFC when precomposition is active.
precompose_os_str_bytes_if_needed
Precompose an OsStr component for directory entries / git paths.
precompose_owned_string_if_needed
Precompose an owned String in place when needed.
precompose_path_if_needed
Precompose each component of a path when needed (for index / pathspec paths).
precompose_string_if_needed
Convert a UTF-8 string from NFD to NFC when precomposition is active.
precompose_unicode_enabled
Whether path precomposition is currently active.
set_precompose_unicode
Enable or disable NFD→NFC path conversion for this process.