From: Johannes Sixt Date: Wed, 11 Nov 2026 07:20:29 GMT Subject: Re: APFS, mmap, and git diff reporting no changes when there are changes? Message-ID: <8b881ed0-f30f-41af-9e59-f4e93006545a@kdbg.org> In-Reply-To: Am 09.11.26 um 23:38 schrieb brian m. carlson: > On 2026-11-09 at 22:05:55, Harold Hunt wrote: >> One could also argue that this is Apple's bug or deficiency. But that >> could take months / years to resolve? > > This behaviour is allowed by POSIX: > > The last data modification and last file status change timestamps of > a file that is mapped with MAP_SHARED and PROT_WRITE shall be marked > for update at some point in the interval between a write reference > to the mapped region and the next call to msync() with MS_ASYNC or > MS_SYNC for that portion of the file by any process. > > However, Git relies on the operating system to reflect an accurate > modification time. If you write files to disk with mmap, then you're > responsible for calling msync() in a timely manner. However, as I said, > that's extremely improvident for things like files in the working tree, > which is why text editors don't use mmap. Not to mention that our mmap emulation for Windows cannot reproduce the Linux behavior (timely update of timestamps) and is more like the macOS behavior (delayed update of timestamps). We cannot have an accurate (atomic) msync emulation, either, because not even FlushViewOfFile[1] updates the timestamp. [1] https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-flushviewoffile -- Hannes