]> git.ipfire.org Git - thirdparty/git.git/commit
mingw_rename: do support directory renames
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 17 Dec 2024 12:52:04 +0000 (12:52 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Dec 2024 20:06:59 +0000 (12:06 -0800)
commitb30404dfc04a4b087b630aea4ab88a51cd3a7459
tree4e07da3ef48140a6115a58f199d47cc9098a1650
parent391bceae4350136a05d977573caeaa07059f2136
mingw_rename: do support directory renames

In 391bceae435 (compat/mingw: support POSIX semantics for atomic
renames, 2024-10-27), we taught the `mingw_rename()` function to respect
POSIX semantics, but we did so only as a fallback after `_wrename()`
fails.

This hid a bug in the implementation that was not caught by Git's test
suite: The `CreateFileW()` function _can_ open handles to directories,
but not when asked to use the `FILE_ATTRIBUTE_NORMAL` flag, as that flag
only is allowed for files.

Let's fix this by using the common `FILE_FLAG_BACKUP_SEMANTICS` flag
that can be used for opening handles to directories, too.

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