merge from git-repair
This commit is contained in:
parent
8217e97d88
commit
ff2b0a9df6
1 changed files with 9 additions and 16 deletions
25
Git/Fsck.hs
25
Git/Fsck.hs
|
@ -17,7 +17,6 @@ import Common
|
||||||
import Git
|
import Git
|
||||||
import Git.Command
|
import Git.Command
|
||||||
import Git.Sha
|
import Git.Sha
|
||||||
import Git.CatFile
|
|
||||||
import Utility.Batch
|
import Utility.Batch
|
||||||
|
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
|
@ -57,24 +56,18 @@ foundBroken (Just s) = not (S.null s)
|
||||||
|
|
||||||
{- Finds objects that are missing from the git repsitory, or are corrupt.
|
{- Finds objects that are missing from the git repsitory, or are corrupt.
|
||||||
-
|
-
|
||||||
- Note that catting a corrupt object will cause cat-file to crash;
|
- This does not use git cat-file --batch, because catting a corrupt
|
||||||
- this is detected and it's restarted.
|
- object can cause it to crash, or to report incorrect size information.
|
||||||
-}
|
-}
|
||||||
findMissing :: [Sha] -> Repo -> IO MissingObjects
|
findMissing :: [Sha] -> Repo -> IO MissingObjects
|
||||||
findMissing objs r = go objs [] =<< start
|
findMissing objs r = S.fromList <$> filterM (not <$$> cancat) objs
|
||||||
where
|
where
|
||||||
start = catFileStart' False r
|
cancat o = either (const False) (const True) <$> tryIO (cat o)
|
||||||
go [] c h = do
|
cat o = runQuiet
|
||||||
void $ tryIO $ catFileStop h
|
[ Param "cat-file"
|
||||||
return $ S.fromList c
|
, Param "-p"
|
||||||
go (o:os) c h = do
|
, Param (show o)
|
||||||
v <- tryNonAsync $ isNothing <$> catObjectDetails h o
|
] r
|
||||||
case v of
|
|
||||||
Left _ -> do
|
|
||||||
void $ tryIO $ catFileStop h
|
|
||||||
go os (o:c) =<< start
|
|
||||||
Right True -> go os (o:c) h
|
|
||||||
Right False -> go os c h
|
|
||||||
|
|
||||||
findShas :: String -> [Sha]
|
findShas :: String -> [Sha]
|
||||||
findShas = catMaybes . map extractSha . concat . map words . lines
|
findShas = catMaybes . map extractSha . concat . map words . lines
|
||||||
|
|
Loading…
Reference in a new issue