diff options
author | Joey Hess <joeyh@debian.org> | 2013-12-03 15:02:21 -0400 |
---|---|---|
committer | Joey Hess <joeyh@debian.org> | 2013-12-03 15:02:21 -0400 |
commit | b1ed0aee347a88507d1530f61006cd658b57e54c (patch) | |
tree | eb2a975663782f83e6b20d6d239447d7222de81b /Git/Fsck.hs | |
parent | 7e592e1d6ed5e0b25b37215da7558c6324688d6f (diff) | |
parent | a4f3e112954e1b785c84c339bcbd83597a89335e (diff) | |
download | git-repair-b1ed0aee347a88507d1530f61006cd658b57e54c.tar.gz |
Record git-repair (1.20131203) in archive suite sid
Diffstat (limited to 'Git/Fsck.hs')
-rw-r--r-- | Git/Fsck.hs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/Git/Fsck.hs b/Git/Fsck.hs index 8bfddb4..8d5b75b 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 @@ -38,21 +37,24 @@ type FsckResults = Maybe MissingObjects -} findBroken :: Bool -> Repo -> IO FsckResults findBroken batchmode r = do + let (command, params) = ("git", fsckParams r) + (command', params') <- if batchmode + then toBatchCommand (command, params) + else return (command, params) (output, fsckok) <- processTranscript command' (toCommand params') Nothing let objs = findShas output badobjs <- findMissing objs r if S.null badobjs && not fsckok - then return Nothing - else return $ Just badobjs - where - (command, params) = ("git", fsckParams r) - (command', params') - | batchmode = toBatchCommand (command, params) - | otherwise = (command, params) + then return FsckFailed + else return $ FsckFoundMissing badobjs 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. - |