#2350 (MoveFile does not report failure when the target exists => Fixed in 2.0.4) – Oracle VirtualBox (original) (raw)

#2350 closed defect (fixed)

Reported by: Owned by:
Component: shared folders Version: VirtualBox 2.0.2
Keywords: git lock rename Cc:
Guest type: Windows Host type: other

As described in ​MSDN, MoveFile should fail if the target file exists.

However, when the files are located in a shared folder, it apparently returns success without actually doing anything. It makes using msysgit with repositories located on shared folders impossible, except in read-only mode.

Steps to reproduce with msysgit:

  1. Install ​MSysGit
  2. Create a shared folder and map it to a drive letter
  3. Try to create a repository on that drive, i.e. mkdir test; cd test; git init (You'll have to enable the "use from windows command prompt" option in the installer)

It'll output a bunch of errors, and leave a .../.git/config.lock file:

error: could not lock config file E:/Work/test/.git/config error: could not lock config file E:/Work/test/.git/config error: could not lock config file E:/Work/test/.git/config error: could not lock config file E:/Work/test/.git/config

Workaround: if I make it ignore the result of rename(), and try MoveFileEx anyway, it works properly:

--- a/compat/mingw.c +++ b/compat/mingw.c @@ -869,11 +869,12 @@ int mingw_rename(const char *pold, const char *pnew) * Try native rename() first to get errno right. * It is based on MoveFile(), which cannot overwrite existing files. */

Guest: Windows 2000 & XP, Host: Fedora 9