diff options
author | Joey Hess <joey@kitenet.net> | 2013-11-20 12:56:03 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-11-20 12:56:03 -0400 |
commit | 3ed32d99829ca44abfe43c953800d8d249909997 (patch) | |
tree | ec52b5fe92a4fc65378682ab1a4ac3b8430a688a | |
parent | d5f6cd563f3caa5dad93667d793bddd726b4d952 (diff) | |
download | git-repair-3ed32d99829ca44abfe43c953800d8d249909997.tar.gz |
avoid corrupting .git/config, at least for now
-rw-r--r-- | Git/Destroyer.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Git/Destroyer.hs b/Git/Destroyer.hs index 7597be8..aae1e9e 100644 --- a/Git/Destroyer.hs +++ b/Git/Destroyer.hs @@ -76,7 +76,8 @@ generateDamage = sample' (arbitrary :: Gen Damage) - (as long as the Repo contains the same files each time). -} applyDamage :: [Damage] -> Repo -> IO () applyDamage l r = do - contents <- sort <$> dirContentsRecursive (localGitDir r) + contents <- sort . filter (not . skipped . takeFileName) + <$> dirContentsRecursive (localGitDir r) forM_ l $ \(Damage action fileselector) -> do let f = selectFile contents fileselector -- Symlinks might be dangling, so are skipped. @@ -85,6 +86,9 @@ applyDamage l r = do whenM (doesFileExist f) $ applyDamageAction action f `catchIO` \e -> error ("Failed to apply " ++ show action ++ " " ++ show f ++ ": " ++ show e ++ "(total damage: " ++ show l ++ ")") + where + -- A broken .git/config is not recoverable. + skipped f = f `elem` [ "config" ] applyDamageAction :: DamageAction -> FilePath -> IO () applyDamageAction Empty f = withSaneMode f $ do |