From: Junio C Hamano Date: Sat, 06 Dec 2025 02:17:55 GMT Subject: Re: [PATCH 03/10] mingw: special-case `open(symlink, O_CREAT | O_EXCL)` Message-ID: In-Reply-To: <4cf1c638-3b0b-a36a-ce35-41d55e9fae12@gmx.de> Johannes Schindelin writes: > On Sat, 29 Nov 2025, Junio C Hamano wrote: > >> "Johannes Schindelin via GitGitGadget" >> writes: >> >> > From: Johannes Schindelin >> > >> > The `_wopen()` function would gladly follow a symbolic link to a >> > non-existent file and create it when given above-mentioned flags. >> > >> > Git expects the `open()` call to fail, though. So let's add yet another >> > work-around to pretend that Windows behaves like Linux. >> >> "like Linux" -> "as POSIX expects"? >> >> cf. https://pubs.opengroup.org/onlinepubs/007904875/functions/open.html#:~:text=If%20O_CREAT%20and%20O_EXCL%20are,set%2C%20the%20result%20is%20undefined. > > You are both correct and incorrect. The behavior I described indeed is not > limited to Linux, insofar you are correct. The behavior I wanted to > imitate is Linux', though, not POSIX. Well, I do not think we require our open() to be so Linux specific that other POSIX compliant systems (e.g., BSDs) would fail. Here, Git expects open() to behave as POSIX specifies, so it is good enough to emulate open() to be sufficiently POSIX, not Linux. Making it like Linux is purely _your_ doing. And it would not help future developers who finds this commit by reading "git log" when they find the code that was changed by this patch in "git blame" output, and they want to further tweak what is left by this patch to fit their needs better while trying to avoid breaking our intent. Our intention is never "open must work like Linux, allowing the caller to rely on Linux-specific quirk that other POSIX implementations may not have", but writing the log as if "a work-around to make it work like Linux" was necessary will mislead them.