2013-10-20 21:50:51 +00:00
|
|
|
{- git-recover-repository program
|
|
|
|
-
|
2013-10-22 18:39:45 +00:00
|
|
|
- Copyright 2013 Joey Hess <joey@kitenet.net>
|
2013-10-20 21:50:51 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
import System.Environment
|
|
|
|
import qualified Data.Set as S
|
2013-10-23 17:13:40 +00:00
|
|
|
import Data.Tuple.Utils
|
2013-10-20 21:50:51 +00:00
|
|
|
|
|
|
|
import Common
|
2013-10-22 17:08:23 +00:00
|
|
|
import qualified Git
|
2013-10-20 21:50:51 +00:00
|
|
|
import qualified Git.CurrentRepo
|
2013-10-22 18:39:45 +00:00
|
|
|
import qualified Git.Fsck
|
2013-10-23 16:58:01 +00:00
|
|
|
import qualified Git.Repair
|
2013-10-20 21:50:51 +00:00
|
|
|
import qualified Git.Config
|
2013-10-21 20:19:00 +00:00
|
|
|
import qualified Git.Branch
|
2013-10-20 21:50:51 +00:00
|
|
|
|
|
|
|
header :: String
|
|
|
|
header = "Usage: git-recover-repository"
|
|
|
|
|
|
|
|
usage :: a
|
|
|
|
usage = error $ "bad parameters\n\n" ++ header
|
|
|
|
|
|
|
|
parseArgs :: IO Bool
|
|
|
|
parseArgs = do
|
|
|
|
args <- getArgs
|
|
|
|
return $ or $ map parse args
|
|
|
|
where
|
|
|
|
parse "--force" = True
|
|
|
|
parse _ = usage
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
|
|
|
forced <- parseArgs
|
|
|
|
|
|
|
|
g <- Git.Config.read =<< Git.CurrentRepo.get
|
2013-10-23 17:13:40 +00:00
|
|
|
ifM (fst3 <$> Git.Repair.runRepair forced g)
|
2013-10-23 16:21:59 +00:00
|
|
|
( exitSuccess
|
|
|
|
, exitFailure
|
|
|
|
)
|