Harold Hunt is working on his own implementation of copy-on-write cloning for Git on some Linux filesystems and on APFS on Mac. In testing around mmap'd files and sharing them across worktrees created with clones, he found that mmap'd files on Mac can make Git commands report no changes, while tools that read the file bytes see the changes. He said he found no discussion of this being an intentional tradeoff of speed over correctness for Git on APFS.

brian m. carlson answered that Git does not use mmap on files that change in place. It maps only content-addressed files such as packs, indexes and, for interoperability code, object maps, whose names contain hashes. It also maps files replaced by rename(2), like the index.

He said it is generally unsafe to mmap files that can change in place. Accessing beyond the end of the file can produce SIGBUS, and a program cannot know when the file was modified, so it would have to cope with crashing anywhere. He cited POSIX text on the timestamps of files mapped with MAP_SHARED and PROT_WRITE, saying the behaviour is allowed.

No further reply from Hunt appears in the excerpts, and no Git bug was identified.