]> git.ipfire.org Git - thirdparty/git.git/commit
mingw: optionally use legacy (non-POSIX) delete semantics
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 7 May 2026 12:51:12 +0000 (12:51 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 May 2026 00:53:12 +0000 (09:53 +0900)
commit69ed0e35a7548a17a0fcd79b265a6872bceb2d5d
tree252b608701b55d6941b36871936839ad0da732d7
parent94f057755b7941b321fd11fec1b2e3ca5313a4e0
mingw: optionally use legacy (non-POSIX) delete semantics

At some point between Windows 10 Build 17134.1304 and Build 18363.657,
the default behavior of `DeleteFileW()` was changed to use POSIX
semantics (https://stackoverflow.com/a/60512798). Under those semantics,
a file can be deleted even when another process holds an active
`MapViewOfFile` view on it: the directory entry is removed immediately,
but the underlying data persists until the last handle is closed.

On older Windows versions (and Windows 10 builds before that change),
`DeleteFileW()` uses legacy semantics where deletion fails outright if
any process holds a file mapping.

To allow testing code paths that depend on the legacy behavior, introduce
a `GIT_TEST_LEGACY_DELETE` environment variable. When set, `mingw_unlink()`
uses `SetFileInformationByHandle()` with `FileDispositionInfo` (the
non-POSIX variant) instead of `DeleteFileW()`, forcing legacy delete
semantics regardless of the Windows version.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c