diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-24 20:08:19 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-24 20:08:19 -0400 |
commit | 313f29e64caa94faac481523fa78d1185f377d83 (patch) | |
tree | 72bca1b458fbbefa6b177e14deae76a21b0fb595 | |
parent | 4bc4117f68865ca2e49b1eb96c97cd9fd67fd0a9 (diff) | |
download | git-repair-313f29e64caa94faac481523fa78d1185f377d83.tar.gz |
Add swapping 2 files test case.
-rw-r--r-- | Git/Destroyer.hs | 14 | ||||
-rw-r--r-- | debian/changelog | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/Git/Destroyer.hs b/Git/Destroyer.hs index afefefa..a84bc60 100644 --- a/Git/Destroyer.hs +++ b/Git/Destroyer.hs @@ -2,7 +2,7 @@ - - Use with caution! - - - Copyright 2013 Joey Hess <joey@kitenet.net> + - Copyright 2013, 2014 Joey Hess <joey@kitenet.net> - - Licensed under the GNU GPL version 3 or higher. -} @@ -17,6 +17,7 @@ import Common import Git import Utility.QuickCheck import Utility.FileMode +import Utility.Tmp import qualified Data.ByteString as B import Data.Word @@ -31,6 +32,7 @@ data Damage | PrependGarbage FileSelector B.ByteString | CorruptByte FileSelector Int Word8 | ScrambleFileMode FileSelector FileMode + | SwapFiles FileSelector FileSelector deriving (Read, Show) instance Arbitrary Damage where @@ -47,6 +49,9 @@ instance Arbitrary Damage where , ScrambleFileMode <$> arbitrary <*> nonNegative arbitrarySizedIntegral + , SwapFiles + <$> arbitrary + <*> arbitrary ] where garbage = B.pack <$> arbitrary `suchThat` (not . null) @@ -124,6 +129,13 @@ applyDamage ds r = do ScrambleFileMode s mode -> withfile s $ \f -> setFileMode f mode + SwapFiles a b -> + withfile a $ \fa -> + withfile b $ \fb -> + withTmpFile "swap" $ \tmp _ -> do + moveFile fa tmp + moveFile fb fa + moveFile tmp fa where -- A broken .git/config is not recoverable. skipped f = f `elem` [ "config" ] diff --git a/debian/changelog b/debian/changelog index bcaccce..6222f5b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ git-repair (1.20140116) UNRELEASED; urgency=medium * Optimise unpacking of pack files, and avoid repeated error messages about corrupt pack files. + * Add swapping 2 files test case. -- Joey Hess <joeyh@debian.org> Mon, 24 Feb 2014 19:39:51 -0400 |