accidentially committed wrong version of file

This commit is contained in:
Joey Hess 2013-12-10 15:45:22 -04:00
parent bc0b8b6465
commit c0ce3269e9

View file

@ -15,6 +15,7 @@ module Git.Repair (
resetLocalBranches, resetLocalBranches,
removeTrackingBranches, removeTrackingBranches,
checkIndex, checkIndex,
checkIndexFast,
missingIndex, missingIndex,
emptyGoodCommits, emptyGoodCommits,
) where ) where
@ -338,13 +339,20 @@ verifyTree missing treesha r
- considered a problem (repo may be new). -} - considered a problem (repo may be new). -}
checkIndex :: Repo -> IO Bool checkIndex :: Repo -> IO Bool
checkIndex r = do checkIndex r = do
(bad, _good, cleanup) <- partitionIndex missing r (bad, _good, cleanup) <- partitionIndex r
if null bad if null bad
then cleanup then cleanup
else do else do
void cleanup void cleanup
return False return False
{- Does not check every object the index refers to, but only that the index
- itself is not corrupt. -}
checkIndexFast :: Repo -> IO Bool
checkIndexFast r = do
(indexcontents, cleanup) <- LsFiles.stagedDetails [repoPath r] r
length indexcontents `seq` cleanup
missingIndex :: Repo -> IO Bool missingIndex :: Repo -> IO Bool
missingIndex r = not <$> doesFileExist (localGitDir r </> "index") missingIndex r = not <$> doesFileExist (localGitDir r </> "index")
@ -352,9 +360,10 @@ missingIndex r = not <$> doesFileExist (localGitDir r </> "index")
partitionIndex :: Repo -> IO ([LsFiles.StagedDetails], [LsFiles.StagedDetails], IO Bool) partitionIndex :: Repo -> IO ([LsFiles.StagedDetails], [LsFiles.StagedDetails], IO Bool)
partitionIndex r = do partitionIndex r = do
(indexcontents, cleanup) <- LsFiles.stagedDetails [repoPath r] r (indexcontents, cleanup) <- LsFiles.stagedDetails [repoPath r] r
l <- forM_ indexcontents $ \i -> case i of l <- forM indexcontents $ \i -> case i of
(_file, Just sha, Just _mode) -> (,) <$> isMissing sha r <*> pure i (_file, Just sha, Just _mode) -> (,) <$> isMissing sha r <*> pure i
_ _> pure (False, i) _ -> pure (False, i)
let (bad, good) = partition fst l
return (map snd bad, map snd good, cleanup) return (map snd bad, map snd good, cleanup)
{- Rewrites the index file, removing from it any files whose blobs are {- Rewrites the index file, removing from it any files whose blobs are
@ -455,7 +464,7 @@ runRepair' fsckresult forced referencerepo g = do
putStrLn "No missing objects found, but the index file is corrupt!" putStrLn "No missing objects found, but the index file is corrupt!"
if forced if forced
then corruptedindex then corruptedindex
else needforce S.empty else needforce
) )
| otherwise -> if forced | otherwise -> if forced
then ifM (checkIndex g) then ifM (checkIndex g)
@ -473,7 +482,7 @@ runRepair' fsckresult forced referencerepo g = do
( do ( do
missing' <- cleanCorruptObjects FsckFailed g missing' <- cleanCorruptObjects FsckFailed g
case missing' of case missing' of
FsckFailed -> return (False, S.empty, []) FsckFailed -> return (False, [])
FsckFoundMissing stillmissing' -> FsckFoundMissing stillmissing' ->
continuerepairs stillmissing' continuerepairs stillmissing'
, corruptedindex , corruptedindex
@ -535,7 +544,7 @@ runRepair' fsckresult forced referencerepo g = do
putStrLn "If you have a clone of this bare repository, you should add it as a remote of this repository, and retry." putStrLn "If you have a clone of this bare repository, you should add it as a remote of this repository, and retry."
putStrLn "If there are no clones of this repository, you can instead retry with the --force parameter to force recovery to a possibly usable state." putStrLn "If there are no clones of this repository, you can instead retry with the --force parameter to force recovery to a possibly usable state."
return (False, []) return (False, [])
else needforce stillmissing else needforce
needforce = do needforce = do
putStrLn "To force a recovery to a usable state, retry with the --force parameter." putStrLn "To force a recovery to a usable state, retry with the --force parameter."
return (False, []) return (False, [])