summaryrefslogtreecommitdiff
path: root/Git/Fsck.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-30 14:29:11 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-30 14:29:11 -0400
commitf04b34c4584e18f4c722700eda5e80eb0345f035 (patch)
tree1c224b92daedc732fa7cd3970603874e8c1fafbe /Git/Fsck.hs
parent9c6587636ef68bd1551f65069118332c337dec48 (diff)
merge improved fsck types from git-repair and some associated changes
Diffstat (limited to 'Git/Fsck.hs')
-rw-r--r--Git/Fsck.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/Git/Fsck.hs b/Git/Fsck.hs
index 8bfddb4ba..8555aa0c1 100644
--- a/Git/Fsck.hs
+++ b/Git/Fsck.hs
@@ -6,11 +6,12 @@
-}
module Git.Fsck (
- FsckResults,
+ FsckResults(..),
MissingObjects,
findBroken,
foundBroken,
findMissing,
+ knownMissing,
) where
import Common
@@ -23,9 +24,7 @@ import qualified Data.Set as S
type MissingObjects = S.Set Sha
-{- If fsck succeeded, Just a set of missing objects it found.
- - If it failed, Nothing. -}
-type FsckResults = Maybe MissingObjects
+data FsckResults = FsckFoundMissing MissingObjects | FsckFailed
{- Runs fsck to find some of the broken objects in the repository.
- May not find all broken objects, if fsck fails on bad data in some of
@@ -42,8 +41,8 @@ findBroken batchmode r = do
let objs = findShas output
badobjs <- findMissing objs r
if S.null badobjs && not fsckok
- then return Nothing
- else return $ Just badobjs
+ then return FsckFailed
+ else return $ FsckFoundMissing badobjs
where
(command, params) = ("git", fsckParams r)
(command', params')
@@ -51,8 +50,12 @@ findBroken batchmode r = do
| otherwise = (command, params)
foundBroken :: FsckResults -> Bool
-foundBroken Nothing = True
-foundBroken (Just s) = not (S.null s)
+foundBroken FsckFailed = True
+foundBroken (FsckFoundMissing s) = not (S.null s)
+
+knownMissing :: FsckResults -> MissingObjects
+knownMissing FsckFailed = S.empty
+knownMissing (FsckFoundMissing s) = s
{- Finds objects that are missing from the git repsitory, or are corrupt.
-