From 82e9a485c5438543a5415ae4c1d870a30d17f605 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 13 Jul 2024 15:52:38 +0300 Subject: [PATCH] Fix renaming symlinks on MS-Windows * src/w32.c (sys_rename_replace): Handle renames of a symlink. This makes 'wdired-tests' succeed on MS-Windows. (cherry picked from commit 5389b6a856b39427846e38b06fa398bafc04836a) --- src/w32.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/w32.c b/src/w32.c index ab45ae8ec6b..6dcbbbcc61b 100644 --- a/src/w32.c +++ b/src/w32.c @@ -4761,6 +4761,15 @@ sys_rename_replace (const char *oldname, const char *newname, BOOL force) strcpy (temp, map_w32_filename (oldname, NULL)); + /* 'rename' (which calls MoveFileW) renames the _target_ of the + symlink, which is different from Posix behavior and not what we + want here. So in that case we pretend this is a cross-device move, + for which Frename_file already has a workaround. */ + if (is_symlink (temp)) + { + errno = EXDEV; + return -1; + } /* volume_info is set indirectly by map_w32_filename. */ oldname_dev = volume_info.serialnum; -- 2.39.2