summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-13 16:47:18 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-13 16:47:18 -0400
commitafac4a4b0a5e5789d43f7cfad62e6d4d53f021aa (patch)
treeac37b0daacfb2ca49859f92ea26cc479ba2dd69b
parentd05e7fea814b51146705fe6623d813011e2bb37c (diff)
repair: better messages when nuking .git/annex/index
-rw-r--r--Command/Repair.hs15
1 files changed, 12 insertions, 3 deletions
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