From 3ed32d99829ca44abfe43c953800d8d249909997 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 20 Nov 2013 12:56:03 -0400 Subject: avoid corrupting .git/config, at least for now --- Git/Destroyer.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3