git/compat
Johannes Schindelin 69ed0e35a7 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>
2026-05-08 09:53:12 +09:00
..
darwin trace2: add macOS process ancestry tracing 2026-02-13 12:18:31 -08:00
fsmonitor global: trivial conversions to fix `-Wsign-compare` warnings 2024-12-06 20:20:04 +09:00
linux treewide: remove unnecessary cache.h inclusion from several sources 2023-03-21 10:56:51 -07:00
nedmalloc unify and bump _WIN32_WINNT definition to Windows 8.1 2026-04-06 10:06:20 -07:00
poll unify and bump _WIN32_WINNT definition to Windows 8.1 2026-04-06 10:06:20 -07:00
regex compat/regex: explicitly mark intentional use of the comma operator 2025-03-28 17:38:11 -07:00
simple-ipc git-compat-util: introduce MEMZERO_ARRAY() macro 2025-12-11 14:44:43 +09:00
stub compat: mark unused parameters in win32/mingw functions 2024-08-28 09:51:18 -07:00
vcbuild mingw.c: Fix complier warnings for a 64 bit msvc 2024-10-17 14:42:27 -04:00
win32 unify and bump _WIN32_WINNT definition to Windows 8.1 2026-04-06 10:06:20 -07:00
.gitattributes
access.c
apple-common-crypto.h
basename.c compat/win32: fix const-correctness with string constants 2024-06-07 10:30:52 -07:00
bswap.h bswap.h: provide a built-in based version of bswap32/64 if possible 2025-07-15 14:36:51 -07:00
compiler.h mingw.c: Fix complier warnings for a 64 bit msvc 2024-10-17 14:42:27 -04:00
disk.h compat: drop inclusion of <git-compat-util.h> 2024-02-24 14:37:41 -08:00
fileno.c
fopen.c
hstrerror.c
inet_ntop.c
inet_pton.c
memmem.c
mingw-posix.h mingw: implement basic `symlink()` functionality (file symlinks only) 2026-01-09 18:32:55 -08:00
mingw.c mingw: optionally use legacy (non-POSIX) delete semantics 2026-05-08 09:53:12 +09:00
mingw.h compat/mingw: split out POSIX-related bits 2025-02-18 10:55:39 -08:00
mkdir.c
mmap.c compat/mmap: mark unused argument in git_munmap() 2025-11-18 09:36:05 -08:00
msvc-posix.h compat/mingw: split out POSIX-related bits 2025-02-18 10:55:39 -08:00
msvc.c
msvc.h compat/mingw: split out POSIX-related bits 2025-02-18 10:55:39 -08:00
nonblock.c
nonblock.h
obstack.c
obstack.h
open.c object-file: move `git_open_cloexec()` to "compat/open.c" 2025-04-15 08:24:35 -07:00
posix.h Revert "compat/posix: introduce writev(3p) wrapper" 2026-04-09 14:48:24 -07:00
pread.c treewide: remove double forward declaration of read_in_full 2023-04-11 08:52:11 -07:00
precompose_utf8.c config: drop `git_config_set()` wrapper 2025-07-23 08:15:21 -07:00
precompose_utf8.h
qsort_s.c
regcomp_enhanced.c regexp: leave a pointer to resurrect workaround for Homebrew 2026-03-25 15:04:30 -07:00
setenv.c
sha1-chunked.c hash-ll: merge with "hash.h" 2024-06-14 10:26:33 -07:00
sha1-chunked.h
snprintf.c
stat.c
strcasestr.c
strdup.c
strlcpy.c
strtoimax.c
strtoumax.c
terminal.c global: trivial conversions to fix `-Wsign-compare` warnings 2024-12-06 20:20:04 +09:00
terminal.h
unsetenv.c
win32.h mingw: teach dirent about symlinks 2026-01-09 18:32:55 -08:00
win32mmap.c global: mark code units that generate warnings with `-Wsign-compare` 2024-12-06 20:20:02 +09:00
winansi.c compat/winansi: drop pre-Vista workaround 2026-04-06 10:06:22 -07:00
zlib-compat.h git-zlib: use `struct z_stream_s` instead of typedef 2025-04-07 14:53:11 -07:00