git/list[1] front-page[2] threads[3] people[4] search[5] about
 

APFS, mmap, and git diff reporting no changes when there are changes?

From
HHHarold Hunt <harold@pwrdrvr.com>
Date
Nov 9, 2026, 22:05 UTC
Message-ID
<CA+-E0BVhYRsktwaUDxtobAXV98dymKg2n4ghod292imymE5C_A@mail.gmail.com>

Hi All - I used to maintain Cygwin/X (the X Server for Cygwin on Windows) 20 years ago... it's been a while since I've used a mailing list.

I'm working on my own implementation of copy on write cloning for git on a couple Linux fs options and APFS on Mac. While working on this I created tests around mmap'd files and how to handle sharing them when creating worktrees with clones.

I discovered that mmap'd files on Mac can cause existing git to misreport no changes on various commands, while tools that read the bytes of the files will see the changed bytes. I could not find any discussion of this being an intentional tradeoff of speed over correctness for git on APFS. I don't believe this is a security problem. However, any tool that mmaps a file, changes it, does not call msync(), and holds that mmap open will cause this misreport to continue until munmap() is called, at which point the ctime of the file changes (mtime does not change on this path).

One could argue that not calling msync() (which updates both ctime and mtime) is bad form and that git not reporting the changes in this case is an acceptable tradeoff for performance reasons. However, on Linux, git correctly detects the changes via the mmap even without calling msync().

One could also argue that this is Apple's bug or deficiency. But that could take months / years to resolve?

I'm writing to ask a few questions before either extracting and
submitting just the tests or carefully vetting the fixes and preparing
my own PRs:
1. Is this already known or is this nothing?
2. How far do we want to go for correctness?
3. Does anyone else have experience with this on APFS and have some advice?

I have an initial LLM-written PR for this on my fork (I am NOT asking for review on this... if you want to look, look, but if you don't want to: please don't): https://github.com/huntharo/git/pull/14

The impact outside of APFS file systems is zero. The trade off on APFS depends on how many files are mmap'd and how large they are. If no files are ever mmap'd by any tools, ever, then the cost can be zero. The technique I'm using looks at generation number being 0 as the indication that we have to examine the file contents as the generation number drops to 0 while mapped.

There is a related follow-on problem: changing a file via mmap/munmap (or any other mechanism that updates ctime but not mtime) in the same second as the last commit will cause git to continue to report no changes even with the file unmapped.

Thanks for any input you can provide here. If these aren't really considered to be a problem then I'll leave them unsolved in my CoW clone patches when I'm ready to submit.

Harold
Next: brian m. carlson
Message 1 of 3 in “APFS, mmap, and git diff reporting no changes when there are changes?”
  1. Harold HuntNov 9, 2026
  2. brian m. carlsonNov 9, 2026
  3. Johannes SixtNov 11, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.