summaryrefslogtreecommitdiff
path: root/Git/Fsck.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-12-10 15:40:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-12-10 15:40:01 -0400
commit6248ad7b2a55d63114851e74279190f424f042ba (patch)
tree68de8099f9f9f8db82eb11243e8baf90b42b7495 /Git/Fsck.hs
parent3890862075dee3e31338fdc85ab6a43324793c97 (diff)
Improve repair of git-annex index file.
Fixes a test case I received where a corrupted repo was repaired, but the git-annex branch was not. The root of the problem was that the MissingObject returned by the repair code was not necessarily a complete set of all objects that might have been deleted during the repair. So, stop trying to return that at all, and instead make the index file checking code explicitly verify that each object the index uses is present.
Diffstat (limited to 'Git/Fsck.hs')
-rw-r--r--Git/Fsck.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Git/Fsck.hs b/Git/Fsck.hs
index 8d5b75bbd..5389d46ef 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]