summaryrefslogtreecommitdiff
path: root/git-recover-repository.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-21 16:19:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-21 16:20:54 -0400
commitafe0cc0bb4fbe3876c35462dece4670617263877 (patch)
treef23797ee89c453d7c82f35e47bb5fc197662a5f4 /git-recover-repository.hs
parent727566ad23efc6c36a4a4473b3299af913f6ce03 (diff)
corrupt branch resetting (but not yet reflog walking)
Diffstat (limited to 'git-recover-repository.hs')
-rw-r--r--git-recover-repository.hs21
1 files changed, 17 insertions, 4 deletions
diff --git a/git-recover-repository.hs b/git-recover-repository.hs
index 66b1708f8..3a002e72c 100644
--- a/git-recover-repository.hs
+++ b/git-recover-repository.hs
@@ -16,6 +16,7 @@ import Common
import qualified Git.CurrentRepo
import qualified Git.RecoverRepository
import qualified Git.Config
+import qualified Git.Branch
header :: String
header = "Usage: git-recover-repository"
@@ -34,7 +35,7 @@ parseArgs = do
enableDebugOutput :: IO ()
enableDebugOutput = do
s <- setFormatter
- <$> streamHandler stderr NOTICE
+ <$> streamHandler stderr DEBUG -- NOTICE
<*> pure (simpleLogFormatter "$msg")
updateGlobalLogger rootLoggerName (setLevel DEBUG . setHandlers [s])
@@ -66,8 +67,20 @@ main = do
, show (length remotebranches)
, "remote tracking branches that referred to missing objects"
]
- localbranches <- Git.RecoverRepository.resetLocalBranches stillmissing goodcommits g
- unless (null localbranches) $ do
+ (resetbranches, deletedbranches, _) <- Git.RecoverRepository.resetLocalBranches stillmissing goodcommits g
+ unless (null resetbranches) $ do
putStrLn "Reset these local branches to old versions before the missing objects were committed:"
- putStr $ unlines $ map show localbranches
+ putStr $ unlines $ map show resetbranches
+ unless (null deletedbranches) $ do
+ putStrLn "Deleted these local branches, which could not be recovered due to missing objects:"
+ putStr $ unlines $ map show deletedbranches
+ mcurr <- Git.Branch.currentUnsafe g
+ case mcurr of
+ Nothing -> return ()
+ Just curr -> when (any (== curr) (resetbranches ++ deletedbranches)) $ do
+ putStrLn $ unwords
+ [ "You currently have"
+ , show curr
+ , "checked out. You may have staged changes in the index that can be committed to recover the lost state of this branch!"
+ ]
else putStrLn "To force a recovery to a usable state, run this command again with the --force parameter."