diff options
author | Joey Hess <joey@kitenet.net> | 2013-11-13 14:39:26 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-11-13 14:39:26 -0400 |
commit | ae73f85e186a196e341cbc7820f1d47cc0f5700c (patch) | |
tree | 4b03969206fd2cd01070eb029cde949b0a4c646f /Git | |
parent | 50aef92c729000ca0f4345e872b99f5a5f032afd (diff) |
better handling of missing index file
Diffstat (limited to 'Git')
-rw-r--r-- | Git/Repair.hs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/Git/Repair.hs b/Git/Repair.hs index 85fcc6680..4265f8796 100644 --- a/Git/Repair.hs +++ b/Git/Repair.hs @@ -13,6 +13,7 @@ module Git.Repair ( resetLocalBranches, removeTrackingBranches, checkIndex, + missingIndex, nukeIndex, emptyGoodCommits, ) where @@ -369,18 +370,19 @@ verifyTree missing treesha r else cleanup {- Checks that the index file only refers to objects that are not missing, - - and is not itself corrupt or missing. -} + - and is not itself corrupt. Note that a missing index file is not + - considered a problem (repo may be new). -} checkIndex :: MissingObjects -> Repo -> IO Bool -checkIndex missing r = ifM (doesFileExist (localGitDir r </> "index")) - ( do - (bad, _good, cleanup) <- partitionIndex missing r - if null bad - then cleanup - else do - void cleanup - return False - , return False - ) +checkIndex missing r = do + (bad, _good, cleanup) <- partitionIndex missing r + if null bad + then cleanup + else do + void cleanup + return False + +missingIndex :: Repo -> IO Bool +missingIndex r = not <$> doesFileExist (localGitDir r </> "index") partitionIndex :: MissingObjects -> Repo -> IO ([LsFiles.StagedDetails], [LsFiles.StagedDetails], IO Bool) partitionIndex missing r = do |