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.
This commit is contained in:
parent
b1ed98636b
commit
ef34316c45
1 changed files with 13 additions and 7 deletions
|
@ -48,7 +48,7 @@ import Data.Tuple.Utils
|
||||||
- Since git fsck may crash on corrupt objects, and so not
|
- Since git fsck may crash on corrupt objects, and so not
|
||||||
- report the full set of corrupt or missing objects,
|
- report the full set of corrupt or missing objects,
|
||||||
- this removes corrupt objects, and re-runs fsck, until it
|
- this removes corrupt objects, and re-runs fsck, until it
|
||||||
- stabalizes.
|
- stabilizes.
|
||||||
-
|
-
|
||||||
- To remove corrupt objects, unpack all packs, and remove the packs
|
- To remove corrupt objects, unpack all packs, and remove the packs
|
||||||
- (to handle corrupt packs), and remove loose object files.
|
- (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."
|
putStrLn "Re-running git fsck to see if it finds more problems."
|
||||||
v <- findBroken False r
|
v <- findBroken False r
|
||||||
case v of
|
case v of
|
||||||
Nothing -> error $ unwords
|
Nothing -> do
|
||||||
|
hPutStrLn stderr $ unwords
|
||||||
[ "git fsck found a problem, which was not corrected after removing"
|
[ "git fsck found a problem, which was not corrected after removing"
|
||||||
, show (S.size oldbad)
|
, show (S.size oldbad)
|
||||||
, "corrupt objects."
|
, "corrupt objects."
|
||||||
]
|
]
|
||||||
|
return S.empty
|
||||||
Just newbad -> do
|
Just newbad -> do
|
||||||
removed <- removeLoose r newbad
|
removed <- removeLoose r newbad
|
||||||
let s = S.union oldbad newbad
|
let s = S.union oldbad newbad
|
||||||
|
@ -516,8 +518,12 @@ runRepairOf fsckresult forced referencerepo g = do
|
||||||
|
|
||||||
corruptedindex = do
|
corruptedindex = do
|
||||||
nukeIndex g
|
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."
|
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
|
successfulfinish stillmissing modifiedbranches = do
|
||||||
mapM_ putStrLn
|
mapM_ putStrLn
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue