summaryrefslogtreecommitdiff
path: root/Command
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 /Command
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 'Command')
-rw-r--r--Command/Repair.hs12
1 files changed, 5 insertions, 7 deletions
diff --git a/Command/Repair.hs b/Command/Repair.hs
index 517e14afc..0cd92268b 100644
--- a/Command/Repair.hs
+++ b/Command/Repair.hs
@@ -12,7 +12,6 @@ import Command
import qualified Annex
import qualified Git.Repair
import qualified Annex.Branch
-import Git.Fsck (MissingObjects)
import Git.Types
import Annex.Version
@@ -28,12 +27,12 @@ start = next $ next $ runRepair =<< Annex.getState Annex.force
runRepair :: Bool -> Annex Bool
runRepair forced = do
- (ok, stillmissing, modifiedbranches) <- inRepo $
+ (ok, modifiedbranches) <- inRepo $
Git.Repair.runRepair forced
-- This command can be run in git repos not using git-annex,
-- so avoid git annex branch stuff in that case.
whenM (isJust <$> getVersion) $
- repairAnnexBranch stillmissing modifiedbranches
+ repairAnnexBranch modifiedbranches
return ok
{- After git repository repair, the .git/annex/index file could
@@ -50,8 +49,8 @@ runRepair forced = do
- yet reflected in the index, this does properly merge those into the
- index before committing.
-}
-repairAnnexBranch :: MissingObjects -> [Branch] -> Annex ()
-repairAnnexBranch missing modifiedbranches
+repairAnnexBranch :: [Branch] -> Annex ()
+repairAnnexBranch modifiedbranches
| Annex.Branch.fullname `elem` modifiedbranches = ifM okindex
( commitindex
, do
@@ -63,8 +62,7 @@ repairAnnexBranch missing modifiedbranches
, nukeindex
)
where
- okindex = Annex.Branch.withIndex $
- inRepo $ Git.Repair.checkIndex missing
+ okindex = Annex.Branch.withIndex $ inRepo $ Git.Repair.checkIndex
commitindex = do
Annex.Branch.forceCommit "committing index after git repository repair"
liftIO $ putStrLn "Successfully recovered the git-annex branch using .git/annex/index"