summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-11-19 17:15:35 -0400
committerJoey Hess <joey@kitenet.net>2013-11-19 17:15:35 -0400
commit0113e018aeb2f425e5e26bcde275d170f15ff03b (patch)
treefd58d04a2444875dac245e172361e9ca3f52f7b8
parent225199aff44949671b1fa848ce6d89945bd2f2f9 (diff)
downloadgit-repair-0113e018aeb2f425e5e26bcde275d170f15ff03b.tar.gz
fix repair failure that occurred when index was corrupted, and other objects too
In this case, the index problem prevented fsck from finding the other problems.
-rw-r--r--Git/Repair.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/Git/Repair.hs b/Git/Repair.hs
index 41d0535..3e731aa 100644
--- a/Git/Repair.hs
+++ b/Git/Repair.hs
@@ -48,7 +48,7 @@ import Data.Tuple.Utils
- Since git fsck may crash on corrupt objects, and so not
- report the full set of corrupt or missing objects,
- this removes corrupt objects, and re-runs fsck, until it
- - stabalizes.
+ - stabilizes.
-
- To remove corrupt objects, unpack all packs, and remove the packs
- (to handle corrupt packs), and remove loose object files.
@@ -79,11 +79,13 @@ cleanCorruptObjects mmissing r = check mmissing
putStrLn "Re-running git fsck to see if it finds more problems."
v <- findBroken False r
case v of
- Nothing -> error $ unwords
- [ "git fsck found a problem, which was not corrected after removing"
- , show (S.size oldbad)
- , "corrupt objects."
- ]
+ Nothing -> do
+ hPutStrLn stderr $ unwords
+ [ "git fsck found a problem, which was not corrected after removing"
+ , show (S.size oldbad)
+ , "corrupt objects."
+ ]
+ return S.empty
Just newbad -> do
removed <- removeLoose r newbad
let s = S.union oldbad newbad
@@ -516,8 +518,12 @@ runRepairOf fsckresult forced referencerepo g = do
corruptedindex = do
nukeIndex g
+ -- The corrupted index can prevent fsck from finding other
+ -- problems, so re-run repair.
+ fsckresult' <- findBroken False g
+ result <- runRepairOf fsckresult' forced referencerepo g
putStrLn "Removed the corrupted index file. You should look at what files are present in your working tree and git add them back to the index when appropriate."
- return (True, S.empty, [])
+ return result
successfulfinish stillmissing modifiedbranches = do
mapM_ putStrLn