diff options
-rw-r--r-- | Git/LockFile.hs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Git/LockFile.hs b/Git/LockFile.hs index ce04ec90a..a7a144114 100644 --- a/Git/LockFile.hs +++ b/Git/LockFile.hs @@ -32,7 +32,22 @@ data LockHandle = LockHandle FilePath HANDLE - time. -} openLock :: FilePath -> IO LockHandle -openLock lck = do +openLock lck = openLock' lck `catchNonAsync` lckerr + where + lckerr e = do + -- Same error message displayed by git. + whenM (doesFileExist lck) $ + hPutStrLn stderr $ unlines + [ "fatal: Unable to create '" ++ lck ++ "': " ++ show e + , "" + , "If no other git process is currently running, this probably means a" + , "git process crashed in this repository earlier. Make sure no other git" + , "process is running and remove the file manually to continue." + ] + throwM e + +openLock' :: FilePath -> IO LockHandle +openLock' lck = do #ifndef mingw32_HOST_OS -- On unix, git simply uses O_EXCL h <- openFd lck ReadWrite (Just 0O666) |