From afac4a4b0a5e5789d43f7cfad62e6d4d53f021aa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 13 Jan 2014 16:47:18 -0400 Subject: repair: better messages when nuking .git/annex/index --- Command/Repair.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Command') diff --git a/Command/Repair.hs b/Command/Repair.hs index 6b45ad6a8..0f02a3ab3 100644 --- a/Command/Repair.hs +++ b/Command/Repair.hs @@ -12,6 +12,7 @@ import Command import qualified Annex import qualified Git.Repair import qualified Annex.Branch +import qualified Git.Ref import Git.Types import Annex.Version @@ -55,18 +56,26 @@ repairAnnexBranch modifiedbranches ( commitindex , do nukeindex - liftIO $ putStrLn "Had to delete the .git/annex/index file as it was corrupt. Since the git-annex branch is not up-to-date anymore. It would be a very good idea to run: git annex fsck --fast" + missingbranch ) | otherwise = ifM okindex ( noop - , nukeindex + , do + nukeindex + ifM (null <$> inRepo (Git.Ref.matching [Annex.Branch.fullname])) + ( missingbranch + , liftIO $ putStrLn "No data was lost." + ) ) where 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" - nukeindex = inRepo $ nukeFile . gitAnnexIndex + nukeindex = do + inRepo $ nukeFile . gitAnnexIndex + liftIO $ putStrLn "Had to delete the .git/annex/index file as it was corrupt." + missingbranch = liftIO $ putStrLn "Since the git-annex branch is not up-to-date anymore. It would be a very good idea to run: git annex fsck --fast" trackingOrSyncBranch :: Ref -> Bool trackingOrSyncBranch b = Git.Repair.isTrackingBranch b || isAnnexSyncBranch b -- cgit v1.2.3