diff options
author | Joey Hess <joey@kitenet.net> | 2014-01-21 13:22:42 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-01-21 13:22:42 -0400 |
commit | d80c547a7d1261f158148ca85e627cc2ecb005f2 (patch) | |
tree | 16296c410c02a85f825211e3ffdefc77f2fc2092 | |
parent | 2fb69f6da944dfbc0881035c23aa1123bc687120 (diff) | |
download | git-repair-d80c547a7d1261f158148ca85e627cc2ecb005f2.tar.gz |
Check git version at run time.
-rw-r--r-- | Git/Fsck.hs | 19 | ||||
-rw-r--r-- | debian/changelog | 1 |
2 files changed, 10 insertions, 10 deletions
diff --git a/Git/Fsck.hs b/Git/Fsck.hs index a49978d..23d3a35 100644 --- a/Git/Fsck.hs +++ b/Git/Fsck.hs @@ -20,7 +20,7 @@ import Git import Git.Command import Git.Sha import Utility.Batch -import qualified Git.BuildVersion +import qualified Git.Version import qualified Data.Set as S @@ -40,12 +40,14 @@ data FsckResults = FsckFoundMissing MissingObjects | FsckFailed -} findBroken :: Bool -> Repo -> IO FsckResults findBroken batchmode r = do - let (command, params) = ("git", fsckParams r) + supportsNoDangling <- (>= Git.Version.normalize "1.7.10") + <$> Git.Version.installed + let (command, params) = ("git", fsckParams supportsNoDangling r) (command', params') <- if batchmode then toBatchCommand (command, params) else return (command, params) (output, fsckok) <- processTranscript command' (toCommand params') Nothing - let objs = findShas output + let objs = findShas supportsNoDangling output badobjs <- findMissing objs r if S.null badobjs && not fsckok then return FsckFailed @@ -75,21 +77,18 @@ isMissing s r = either (const True) (const False) <$> tryIO dump , Param (show s) ] r -findShas :: String -> [Sha] -findShas = catMaybes . map extractSha . concat . map words . filter wanted . lines +findShas :: Bool -> String -> [Sha] +findShas supportsNoDangling = catMaybes . map extractSha . concat . map words . filter wanted . lines where wanted l | supportsNoDangling = True | otherwise = not ("dangling " `isPrefixOf` l) -fsckParams :: Repo -> [CommandParam] -fsckParams = gitCommandLine $ map Param $ catMaybes +fsckParams :: Bool -> Repo -> [CommandParam] +fsckParams supportsNoDangling = gitCommandLine $ map Param $ catMaybes [ Just "fsck" , if supportsNoDangling then Just "--no-dangling" else Nothing , Just "--no-reflogs" ] - -supportsNoDangling :: Bool -supportsNoDangling = not $ Git.BuildVersion.older "1.7.10" diff --git a/debian/changelog b/debian/changelog index f44064c..4a9ab76 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ git-repair (1.20140115) unstable; urgency=medium implemented. * Fix bug in packed refs file exploding code that caused a .gitrefs directory to be created instead of .git/refs + * Check git version at run time. -- Joey Hess <joeyh@debian.org> Wed, 15 Jan 2014 16:53:30 -0400 |