diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-03-03 13:05:00 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-03-03 13:06:39 -0400 |
commit | b05583e78fdab70c157aad0c405a22b5ae164e30 (patch) | |
tree | ab7e3882ffbbd5821f90619afeb4c68ab97f2870 /Git | |
parent | edbe3319433ebec420954350b4b63b7bfcc58c83 (diff) |
replicate git's message about an existing lock file
Diffstat (limited to 'Git')
-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) |