diff options
author | Joey Hess <joeyh@joeyh.name> | 2023-08-14 12:06:32 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2023-08-14 12:12:52 -0400 |
commit | edf83982be214f3c839fab9b659f645de53a9100 (patch) | |
tree | bef06cb750379c6d7942fc13b13fcb328201354c /Git/Destroyer.hs | |
parent | f0cd3a2a3758ddcd2f0900c16bdc1fb80bbd6e92 (diff) | |
download | git-repair-edf83982be214f3c839fab9b659f645de53a9100.tar.gz |
merge from git-annex
Support building with unix-compat 0.7
Diffstat (limited to 'Git/Destroyer.hs')
-rw-r--r-- | Git/Destroyer.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Git/Destroyer.hs b/Git/Destroyer.hs index 4d84eec..9b75178 100644 --- a/Git/Destroyer.hs +++ b/Git/Destroyer.hs @@ -18,7 +18,9 @@ import Git import Utility.QuickCheck import Utility.FileMode import Utility.Tmp +import qualified Utility.RawFilePath as R +import System.PosixCompat.Files import qualified Data.ByteString as B import Data.Word @@ -95,12 +97,12 @@ applyDamage ds r = do case d of Empty s -> withfile s $ \f -> withSaneMode f $ do - removeWhenExistsWith removeLink f + removeWhenExistsWith R.removeLink (toRawFilePath f) writeFile f "" Reverse s -> withfile s $ \f -> withSaneMode f $ B.writeFile f =<< B.reverse <$> B.readFile f - Delete s -> withfile s $ removeWhenExistsWith removeLink + Delete s -> withfile s $ removeWhenExistsWith R.removeLink . toRawFilePath AppendGarbage s garbage -> withfile s $ \f -> withSaneMode f $ @@ -127,15 +129,15 @@ applyDamage ds r = do ] ScrambleFileMode s mode -> withfile s $ \f -> - setFileMode f mode + R.setFileMode (toRawFilePath f) mode SwapFiles a b -> withfile a $ \fa -> withfile b $ \fb -> unless (fa == fb) $ withTmpFile "swap" $ \tmp _ -> do - moveFile fa tmp - moveFile fb fa - moveFile tmp fa + moveFile (toRawFilePath fa) (toRawFilePath tmp) + moveFile (toRawFilePath fb) (toRawFilePath fa) + moveFile (toRawFilePath tmp) (toRawFilePath fa) where -- A broken .git/config is not recoverable. -- Don't damage hook scripts, to avoid running arbitrary code. ;) |