diff options
Diffstat (limited to 'Git')
-rw-r--r-- | Git/CheckAttr.hs | 12 | ||||
-rw-r--r-- | Git/Remote/Remove.hs | 22 | ||||
-rw-r--r-- | Git/Version.hs | 6 |
3 files changed, 24 insertions, 16 deletions
diff --git a/Git/CheckAttr.hs b/Git/CheckAttr.hs index 6b5e3bf62..bf46b938f 100644 --- a/Git/CheckAttr.hs +++ b/Git/CheckAttr.hs @@ -10,12 +10,12 @@ module Git.CheckAttr where import Common import Git import Git.Command -import qualified Git.BuildVersion +import qualified Git.Version import qualified Utility.CoProcess as CoProcess import System.IO.Error -type CheckAttrHandle = (CoProcess.CoProcessHandle, [Attr], String) +type CheckAttrHandle = (CoProcess.CoProcessHandle, [Attr], Bool, String) type Attr = String @@ -25,7 +25,8 @@ checkAttrStart :: [Attr] -> Repo -> IO CheckAttrHandle checkAttrStart attrs repo = do currdir <- getCurrentDirectory h <- CoProcess.rawMode =<< gitCoProcessStart True params repo - return (h, attrs, currdir) + oldgit <- Git.Version.older "1.7.7" + return (h, attrs, oldgit, currdir) where params = [ Param "check-attr" @@ -34,11 +35,11 @@ checkAttrStart attrs repo = do [ Param "--" ] checkAttrStop :: CheckAttrHandle -> IO () -checkAttrStop (h, _, _) = CoProcess.stop h +checkAttrStop (h, _, _, _) = CoProcess.stop h {- Gets an attribute of a file. -} checkAttr :: CheckAttrHandle -> Attr -> FilePath -> IO String -checkAttr (h, attrs, currdir) want file = do +checkAttr (h, attrs, oldgit, currdir) want file = do pairs <- CoProcess.query h send (receive "") let vals = map snd $ filter (\(attr, _) -> attr == want) pairs case vals of @@ -81,7 +82,6 @@ checkAttr (h, attrs, currdir) want file = do - With newer git, git check-attr chokes on some absolute - filenames, and the bugs that necessitated them were fixed, - so use relative filenames. -} - oldgit = Git.BuildVersion.older "1.7.7" file' | oldgit = absPathFrom currdir file | otherwise = relPathDirToFile currdir $ absPathFrom currdir file diff --git a/Git/Remote/Remove.hs b/Git/Remote/Remove.hs index 949019b22..ab1da9cde 100644 --- a/Git/Remote/Remove.hs +++ b/Git/Remote/Remove.hs @@ -13,15 +13,17 @@ import Common import Git import Git.Types import qualified Git.Command -import qualified Git.BuildVersion +import qualified Git.Version remove :: RemoteName -> Repo -> IO () -remove remotename = Git.Command.run - [ Param "remote" - -- name of this subcommand changed - , Param $ - if Git.BuildVersion.older "1.8.0" - then "rm" - else "remove" - , Param remotename - ] +remove remotename r = do + old <- Git.Version.older "1.8.0" + Git.Command.run + [ Param "remote" + -- name of this subcommand changed + , Param $ + if old + then "rm" + else "remove" + , Param remotename + ] r diff --git a/Git/Version.hs b/Git/Version.hs index 1c53b4bfd..73ce2f81d 100644 --- a/Git/Version.hs +++ b/Git/Version.hs @@ -7,6 +7,7 @@ module Git.Version ( installed, + older, normalize, GitVersion, ) where @@ -22,3 +23,8 @@ installed = normalize . extract <$> readProcess "git" ["--version"] extract s = case lines s of [] -> "" (l:_) -> unwords $ drop 2 $ words l + +older :: String -> IO Bool +older n = do + v <- installed + return $ v < normalize n |