summaryrefslogtreecommitdiff
path: root/git-recover-repository.hs
blob: 3e348f5bba4680c3d990de7a0b2c60e9f70ca195 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{- git-recover-repository program
 -
 - Copyright 2013 Joey Hess <joey@kitenet.net>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

import System.Environment
import qualified Data.Set as S
import Data.Tuple.Utils

import Common
import qualified Git
import qualified Git.CurrentRepo
import qualified Git.Fsck
import qualified Git.Repair
import qualified Git.Config
import qualified Git.Branch

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
	ifM (fst3 <$> Git.Repair.runRepair forced g)
		( exitSuccess
		, exitFailure
		)