From dd1d8e69d4c190c7bb60d5187f7a889c6fea0d62 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 13 Jan 2014 18:08:39 -0400 Subject: Support old git versions from before git fsck --no-dangling was implemented. --- Git/Fsck.hs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'Git') diff --git a/Git/Fsck.hs b/Git/Fsck.hs index 5389d46..a49978d 100644 --- a/Git/Fsck.hs +++ b/Git/Fsck.hs @@ -20,6 +20,7 @@ import Git import Git.Command import Git.Sha import Utility.Batch +import qualified Git.BuildVersion import qualified Data.Set as S @@ -75,11 +76,20 @@ isMissing s r = either (const True) (const False) <$> tryIO dump ] r findShas :: String -> [Sha] -findShas = catMaybes . map extractSha . concat . map words . lines +findShas = catMaybes . map extractSha . concat . map words . filter wanted . lines + where + wanted l + | supportsNoDangling = True + | otherwise = not ("dangling " `isPrefixOf` l) fsckParams :: Repo -> [CommandParam] -fsckParams = gitCommandLine $ - [ Param "fsck" - , Param "--no-dangling" - , Param "--no-reflogs" +fsckParams = 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" -- cgit v1.2.3