diff --git a/Annex/Branch.hs b/Annex/Branch.hs index a890668810..8f0a09fd6b 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -141,7 +141,7 @@ update = onceonly $ do let merge_desc = if null branches then "update" else "merging " ++ - (unwords $ map (show . Git.refDescribe) branches) ++ + unwords (map (show . Git.refDescribe) branches) ++ " into " ++ show name unless (null branches) $ do showSideAction merge_desc diff --git a/Annex/Content.hs b/Annex/Content.hs index 90bde2975a..3f1db37b53 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -43,7 +43,7 @@ import Annex.Exception {- Checks if a given key's content is currently present. -} inAnnex :: Key -> Annex Bool -inAnnex = inAnnex' $ doesFileExist +inAnnex = inAnnex' doesFileExist inAnnex' :: (FilePath -> IO a) -> Key -> Annex a inAnnex' a key = do whenM (fromRepo Git.repoIsUrl) $ diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs index f8cd5d9bc8..6893f94ef4 100644 --- a/Annex/Ssh.hs +++ b/Annex/Ssh.hs @@ -43,7 +43,7 @@ git_annex_shell r command params shellcmd = "git-annex-shell" shellopts = Param command : File dir : params sshcmd uuid = unwords $ - shellcmd : (map shellEscape $ toCommand shellopts) ++ + shellcmd : map shellEscape (toCommand shellopts) ++ uuidcheck uuid uuidcheck NoUUID = [] uuidcheck (UUID u) = ["--uuid", u] diff --git a/CmdLine.hs b/CmdLine.hs index 78f46a2e39..672969c30a 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -32,7 +32,7 @@ dispatch args cmds options header getgitrepo = do setupConsole r <- E.try getgitrepo :: IO (Either E.SomeException Git.Repo) case r of - Left e -> maybe (throw e) id (cmdnorepo cmd) + Left e -> fromMaybe (throw e) (cmdnorepo cmd) Right g -> do state <- Annex.new g (actions, state') <- Annex.run state $ do diff --git a/Command.hs b/Command.hs index 0cd0bf4910..86a83e30c0 100644 --- a/Command.hs +++ b/Command.hs @@ -73,7 +73,7 @@ doCommand = start whenAnnexed :: (FilePath -> (Key, Backend Annex) -> Annex (Maybe a)) -> FilePath -> Annex (Maybe a) whenAnnexed a file = ifAnnexed file (a file) (return Nothing) -ifAnnexed :: FilePath -> ((Key, Backend Annex) -> Annex a) -> (Annex a) -> Annex a +ifAnnexed :: FilePath -> ((Key, Backend Annex) -> Annex a) -> Annex a -> Annex a ifAnnexed file yes no = maybe no yes =<< Backend.lookupFile file notBareRepo :: Annex a -> Annex a diff --git a/Command/Map.hs b/Command/Map.hs index 6b1e8d5bbc..57b48d5030 100644 --- a/Command/Map.hs +++ b/Command/Map.hs @@ -203,7 +203,7 @@ tryScan r "git config --list" dir = Git.workTree r cddir - | take 2 dir == "/~" = + | "/~" `isPrefixOf` dir = let (userhome, reldir) = span (/= '/') (drop 1 dir) in "cd " ++ userhome ++ " && cd " ++ shellEscape (drop 1 reldir) | otherwise = "cd " ++ shellEscape dir diff --git a/Command/Status.hs b/Command/Status.hs index 0fefda1f6b..09da41987b 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -191,9 +191,8 @@ staleSize label dirspec = do keys <- lift (Command.Unused.staleKeys dirspec) if null keys then nostat - else do - stat label $ json (++ aside "clean up with git-annex unused") $ - return $ keySizeSum $ S.fromList keys + else stat label $ json (++ aside "clean up with git-annex unused") $ + return $ keySizeSum $ S.fromList keys aside :: String -> String aside s = " (" ++ s ++ ")" diff --git a/Command/Unused.hs b/Command/Unused.hs index 7f9edfef25..be0107752e 100644 --- a/Command/Unused.hs +++ b/Command/Unused.hs @@ -152,13 +152,12 @@ excludeReferenced l = do (S.fromList l) where -- Skip the git-annex branches, and get all other unique refs. - refs = map Git.Ref . - map last . + refs = map (Git.Ref . last) . nubBy cmpheads . filter ourbranches . map words . lines . L.unpack cmpheads a b = head a == head b - ourbranchend = '/' : show (Annex.Branch.name) + ourbranchend = '/' : show Annex.Branch.name ourbranches ws = not $ ourbranchend `isSuffixOf` last ws removewith [] s = return $ S.toList s removewith (a:as) s diff --git a/Git/UnionMerge.hs b/Git/UnionMerge.hs index edc8cb20ba..ddbff6a82f 100644 --- a/Git/UnionMerge.hs +++ b/Git/UnionMerge.hs @@ -48,7 +48,7 @@ merge_index h repo bs = - earlier ones, so the list can be generated from any combination of - ls_tree, merge_trees, and merge_tree_index. -} update_index :: Repo -> [String] -> IO () -update_index repo ls = stream_update_index repo [\s -> mapM_ s ls] +update_index repo ls = stream_update_index repo [(`mapM_` ls)] {- Streams content into update-index. -} stream_update_index :: Repo -> [Streamer] -> IO () diff --git a/Logs/UUID.hs b/Logs/UUID.hs index 20f43d15ca..b325c78b6f 100644 --- a/Logs/UUID.hs +++ b/Logs/UUID.hs @@ -55,15 +55,15 @@ fixBadUUID = M.fromList . map fixup . M.toList | otherwise = (k, v) where kuuid = fromUUID k - isbad = (not $ isuuid kuuid) && isuuid lastword + isbad = not (isuuid kuuid) && isuuid lastword ws = words $ value v lastword = last ws fixeduuid = toUUID lastword - fixedvalue = unwords $ kuuid:(take (length ws - 1) ws) + fixedvalue = unwords $ kuuid: init ws -- For the fixed line to take precidence, it should be -- slightly newer, but only slightly. newertime (LogEntry (Date d) _) = d + minimumPOSIXTimeSlice - newertime (LogEntry (Unknown) _) = minimumPOSIXTimeSlice + newertime (LogEntry Unknown _) = minimumPOSIXTimeSlice minimumPOSIXTimeSlice = 0.000001 isuuid s = length s == 36 && length (split "-" s) == 5 diff --git a/Remote/Git.hs b/Remote/Git.hs index 99ca9fe8e2..d172ec7c04 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -165,7 +165,7 @@ onLocal :: Git.Repo -> Annex a -> IO a onLocal r a = do -- Avoid re-reading the repository's configuration if it was -- already read. - state <- if (M.null $ Git.configMap r) + state <- if M.null $ Git.configMap r then Annex.new r else return $ Annex.newState r Annex.eval state $ do diff --git a/Upgrade/V2.hs b/Upgrade/V2.hs index e76d99b3ec..08bf83e837 100644 --- a/Upgrade/V2.hs +++ b/Upgrade/V2.hs @@ -53,7 +53,7 @@ upgrade = do when e $ do inRepo $ Git.run "rm" [Param "-r", Param "-f", Param "-q", File old] - unless bare $ inRepo $ gitAttributesUnWrite + unless bare $ inRepo gitAttributesUnWrite showProgress unless bare push diff --git a/Utility/DataUnits.hs b/Utility/DataUnits.hs index e7552f52fb..5d80a04b9c 100644 --- a/Utility/DataUnits.hs +++ b/Utility/DataUnits.hs @@ -99,7 +99,7 @@ bandwidthUnits = error "stop trying to rip people off" {- Do you yearn for the days when men were men and megabytes were megabytes? -} oldSchoolUnits :: [Unit] -oldSchoolUnits = map mingle $ zip storageUnits memoryUnits +oldSchoolUnits = zipWith (curry mingle) storageUnits memoryUnits where mingle (Unit _ a n, Unit s' _ _) = Unit s' a n diff --git a/Utility/Directory.hs b/Utility/Directory.hs index 7f8822fca5..249ed69356 100644 --- a/Utility/Directory.hs +++ b/Utility/Directory.hs @@ -11,6 +11,7 @@ import System.IO.Error import System.Posix.Files import System.Directory import Control.Exception (throw) +import Control.Monad import Utility.SafeCommand import Utility.Conditional @@ -37,13 +38,11 @@ moveFile src dest = try (rename src dest) >>= onrename mv tmp _ = do ok <- boolSystem "mv" [Param "-f", Param src, Param tmp] - if ok - then return () - else do - -- delete any partial - _ <- try $ - removeFile tmp - rethrow + unless ok $ do + -- delete any partial + _ <- try $ + removeFile tmp + rethrow isdir f = do r <- try (getFileStatus f) case r of diff --git a/configure.hs b/configure.hs index cb73af2a99..0d96b39554 100644 --- a/configure.hs +++ b/configure.hs @@ -71,7 +71,7 @@ checkGitVersion = do dotted = sum . mult 1 . reverse . extend 10 . map readi . split "." extend n l = l ++ replicate (n - length l) 0 mult _ [] = [] - mult n (x:xs) = (n*x) : (mult (n*100) xs) + mult n (x:xs) = (n*x) : mult (n*100) xs readi :: String -> Integer readi s = case reads s of ((x,_):_) -> x diff --git a/test.hs b/test.hs index e625fbd756..91c11873da 100644 --- a/test.hs +++ b/test.hs @@ -11,11 +11,10 @@ import Test.QuickCheck import System.Posix.Directory (changeWorkingDirectory) import System.Posix.Files -import Control.Exception (bracket_, bracket) +import Control.Exception (bracket_, bracket, throw) import System.IO.Error import System.Posix.Env import qualified Control.Exception.Extensible as E -import Control.Exception (throw) import qualified Data.Map as M import System.IO.HVFS (SystemFS(..))