merge with git-repair

This commit is contained in:
Joey Hess 2013-11-19 17:08:57 -04:00
parent 423e933800
commit b1ed98636b
5 changed files with 12 additions and 5 deletions

View file

@ -46,6 +46,4 @@ fieldTransfer direction key a = do
ok <- maybe (a $ const noop) ok <- maybe (a $ const noop)
(\u -> runTransfer (Transfer direction (toUUID u) key) afile noRetry a) (\u -> runTransfer (Transfer direction (toUUID u) key) afile noRetry a)
=<< Fields.getField Fields.remoteUUID =<< Fields.getField Fields.remoteUUID
liftIO $ if ok liftIO $ exitBool ok
then exitSuccess
else exitFailure

View file

@ -56,4 +56,4 @@ fromPerform remote key file = go $
getViaTmp key $ \t -> Remote.retrieveKeyFile remote key file t p getViaTmp key $ \t -> Remote.retrieveKeyFile remote key file t p
go :: Annex Bool -> CommandPerform go :: Annex Bool -> CommandPerform
go a = ifM a ( liftIO exitSuccess, liftIO exitFailure) go a = a >>= liftIO . exitBool

View file

@ -8,6 +8,7 @@
module Git.Repair ( module Git.Repair (
runRepair, runRepair,
runRepairOf, runRepairOf,
successfulRepair,
cleanCorruptObjects, cleanCorruptObjects,
retrieveMissingObjects, retrieveMissingObjects,
resetLocalBranches, resetLocalBranches,
@ -452,6 +453,9 @@ runRepair forced g = do
putStrLn "No problems found." putStrLn "No problems found."
return (True, S.empty, []) return (True, S.empty, [])
successfulRepair :: (Bool, MissingObjects, [Branch]) -> Bool
successfulRepair = fst3
runRepairOf :: FsckResults -> Bool -> Maybe FilePath -> Repo -> IO (Bool, MissingObjects, [Branch]) runRepairOf :: FsckResults -> Bool -> Maybe FilePath -> Repo -> IO (Bool, MissingObjects, [Branch])
runRepairOf fsckresult forced referencerepo g = do runRepairOf fsckresult forced referencerepo g = do
missing <- cleanCorruptObjects fsckresult g missing <- cleanCorruptObjects fsckresult g

View file

@ -15,6 +15,7 @@ import Foreign
import Data.Char import Data.Char
import Data.List import Data.List
import Control.Applicative import Control.Applicative
import System.Exit
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
import System.Posix.Process (getAnyProcessStatus) import System.Posix.Process (getAnyProcessStatus)
import Utility.Exception import Utility.Exception
@ -136,3 +137,7 @@ reapZombies = do
#else #else
reapZombies = return () reapZombies = return ()
#endif #endif
exitBool :: Bool -> IO a
exitBool False = exitFailure
exitBool True = exitSuccess

View file

@ -62,7 +62,7 @@ withTmpDirIn :: FilePath -> Template -> (FilePath -> IO a) -> IO a
withTmpDirIn tmpdir template = bracket create remove withTmpDirIn tmpdir template = bracket create remove
where where
remove d = whenM (doesDirectoryExist d) $ remove d = whenM (doesDirectoryExist d) $
removeDirectoryRecursive d return () -- removeDirectoryRecursive d
create = do create = do
createDirectoryIfMissing True tmpdir createDirectoryIfMissing True tmpdir
makenewdir (tmpdir </> template) (0 :: Int) makenewdir (tmpdir </> template) (0 :: Int)