diff options
author | Joey Hess <joey@kitenet.net> | 2013-12-10 15:46:51 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-12-10 15:48:18 -0400 |
commit | 444a4dad77289265296d1fa76e060c46497ec6c8 (patch) | |
tree | 8195b01fd8f0058d738660430038da23b57ee082 /Git/Fsck.hs | |
parent | a0aab76ae762614041720dd55d63ed3e0b7c1c94 (diff) | |
download | git-repair-444a4dad77289265296d1fa76e060c46497ec6c8.tar.gz |
merge from git-annex
Diffstat (limited to 'Git/Fsck.hs')
-rw-r--r-- | Git/Fsck.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Git/Fsck.hs b/Git/Fsck.hs index 8d5b75b..5389d46 100644 --- a/Git/Fsck.hs +++ b/Git/Fsck.hs @@ -11,6 +11,7 @@ module Git.Fsck ( findBroken, foundBroken, findMissing, + isMissing, knownMissing, ) where @@ -25,6 +26,7 @@ import qualified Data.Set as S type MissingObjects = S.Set Sha data FsckResults = FsckFoundMissing MissingObjects | FsckFailed + deriving (Show) {- 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 @@ -59,15 +61,17 @@ knownMissing (FsckFoundMissing s) = s {- Finds objects that are missing from the git repsitory, or are corrupt. - - This does not use git cat-file --batch, because catting a corrupt - - object can cause it to crash, or to report incorrect size information.a + - object can cause it to crash, or to report incorrect size information. -} findMissing :: [Sha] -> Repo -> IO MissingObjects -findMissing objs r = S.fromList <$> filterM (not <$$> present) objs +findMissing objs r = S.fromList <$> filterM (`isMissing` r) objs + +isMissing :: Sha -> Repo -> IO Bool +isMissing s r = either (const True) (const False) <$> tryIO dump where - present o = either (const False) (const True) <$> tryIO (dump o) - dump o = runQuiet + dump = runQuiet [ Param "show" - , Param (show o) + , Param (show s) ] r findShas :: String -> [Sha] |