summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Annex.hs3
-rw-r--r--Backend/File.hs5
-rw-r--r--Commands.hs9
-rw-r--r--Core.hs23
-rw-r--r--GitQueue.hs5
-rw-r--r--GitRepo.hs3
-rw-r--r--Remotes.hs7
-rw-r--r--UUID.hs14
-rw-r--r--git-annex.hs11
9 files changed, 30 insertions, 50 deletions
diff --git a/Annex.hs b/Annex.hs
index 0e8ec2b7b..60ae91708 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -61,7 +61,6 @@ gitRepoChange :: Git.Repo -> Annex ()
gitRepoChange r = do
state <- get
put state { Internals.repo = r }
- return ()
{- Returns the backends being used. -}
backends :: Annex [Backend]
@@ -74,7 +73,6 @@ backendsChange :: [Backend] -> Annex ()
backendsChange b = do
state <- get
put state { Internals.backends = b }
- return ()
{- Returns the full list of supported backends. -}
supportedBackends :: Annex [Backend]
@@ -95,7 +93,6 @@ flagChange :: FlagName -> Flag -> Annex ()
flagChange name val = do
state <- get
put state { Internals.flags = M.insert name val $ Internals.flags state }
- return ()
{- Gets the value of a String flag (or "" if there is no such String flag) -}
flagGet :: FlagName -> Annex String
diff --git a/Backend/File.hs b/Backend/File.hs
index 4b9a3b45b..b45354752 100644
--- a/Backend/File.hs
+++ b/Backend/File.hs
@@ -129,7 +129,7 @@ checkRemoveKey key = do
"Could only verify the existence of " ++
(show have) ++ " out of " ++ (show need) ++
" necessary copies"
- if (not $ null bad) then showTriedRemotes bad else return ()
+ showTriedRemotes bad
showLocations key
hint
return False
@@ -146,7 +146,8 @@ showLocations key = do
if (null uuidsf)
then showLongNote $ "No other repository is known to contain the file."
else showLongNote $ "Try making some of these repositories available:\n" ++ ppuuids
-
+
+showTriedRemotes [] = return ()
showTriedRemotes remotes =
showLongNote $ "I was unable to access these remotes: " ++
(Remotes.list remotes)
diff --git a/Commands.hs b/Commands.hs
index 6974b697c..a46b9fb16 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -14,6 +14,7 @@ import System.Directory
import System.Path
import Data.String.Utils
import Control.Monad (filterM)
+import Monad (when)
import List
import IO
@@ -326,9 +327,7 @@ dropKeyCleanup key = do
setKeyStart :: FilePath -> Annex (Maybe SubCmdPerform)
setKeyStart tmpfile = do
keyname <- Annex.flagGet "key"
- if (null keyname)
- then error "please specify the key with --key"
- else return ()
+ when (null keyname) $ error "please specify the key with --key"
backends <- Backend.list
let key = genKey (backends !! 0) keyname
return $ Just $ setKeyPerform tmpfile key
@@ -392,9 +391,7 @@ initCleanup = do
fromKeyStart :: FilePath -> Annex (Maybe SubCmdPerform)
fromKeyStart file = do
keyname <- Annex.flagGet "key"
- if (null keyname)
- then error "please specify the key with --key"
- else return ()
+ when (null keyname) $ error "please specify the key with --key"
backends <- Backend.list
let key = genKey (backends !! 0) keyname
diff --git a/Core.hs b/Core.hs
index e0993a53e..cf97768c7 100644
--- a/Core.hs
+++ b/Core.hs
@@ -13,6 +13,7 @@ import System.Directory
import Control.Monad.State (liftIO)
import System.Path
import Data.String.Utils
+import Monad (when, unless)
import Types
import Locations
@@ -37,19 +38,15 @@ shutdown = do
-- Runs all queued git commands.
q <- Annex.queueGet
- if (q == GitQueue.empty)
- then return ()
- else do
- verbose $ liftIO $ putStrLn "Recording state in git..."
- liftIO $ GitQueue.run g q
+ unless (q == GitQueue.empty) $ do
+ verbose $ liftIO $ putStrLn "Recording state in git..."
+ liftIO $ GitQueue.run g q
-- clean up any files left in the temp directory, but leave
-- the tmp directory itself
let tmp = annexTmpLocation g
exists <- liftIO $ doesDirectoryExist tmp
- if (exists)
- then liftIO $ removeDirectoryRecursive $ tmp
- else return ()
+ when (exists) $ liftIO $ removeDirectoryRecursive $ tmp
liftIO $ createDirectoryIfMissing True tmp
return True
@@ -65,11 +62,9 @@ gitAttributes repo = do
commit
else do
content <- readFile attributes
- if (all (/= attrLine) (lines content))
- then do
- appendFile attributes $ attrLine ++ "\n"
- commit
- else return ()
+ when (all (/= attrLine) (lines content)) $ do
+ appendFile attributes $ attrLine ++ "\n"
+ commit
where
attrLine = stateLoc ++ "*.log merge=union"
attributes = Git.attributes repo
@@ -150,7 +145,7 @@ getViaTmp key action = do
verbose :: Annex () -> Annex ()
verbose a = do
q <- Annex.flagIsSet "quiet"
- if (q) then return () else a
+ unless q a
showStart :: String -> String -> Annex ()
showStart command file = verbose $ do
liftIO $ putStr $ command ++ " " ++ file ++ " "
diff --git a/GitQueue.hs b/GitQueue.hs
index 6a68edb25..09b8037e6 100644
--- a/GitQueue.hs
+++ b/GitQueue.hs
@@ -16,6 +16,7 @@ import qualified Data.Map as M
import System.IO
import System.Cmd.Utils
import Data.String.Utils
+import Monad (unless)
import qualified GitRepo as Git
@@ -52,9 +53,7 @@ run repo queue = do
- Complicated by commandline length limits. -}
runAction :: Git.Repo -> Action -> [FilePath] -> IO ()
runAction repo action files = do
- if (null files)
- then return ()
- else runxargs
+ unless (null files) runxargs
where
runxargs = pOpen WriteToPipe "xargs"
(["-0", "git", subcommand action] ++ (params action))
diff --git a/GitRepo.hs b/GitRepo.hs
index 0e87c9526..d0fac96c1 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -191,8 +191,7 @@ gitCommandLine repo params = assertLocal repo $
{- Runs git in the specified repo. -}
run :: Repo -> [String] -> IO ()
run repo params = assertLocal repo $ do
- r <- safeSystem "git" (gitCommandLine repo params)
- return ()
+ safeSystem "git" (gitCommandLine repo params)
{- Runs a git subcommand and returns its output. -}
pipeRead :: Repo -> [String] -> IO String
diff --git a/Remotes.hs b/Remotes.hs
index bee98a6f3..02d4dc9c2 100644
--- a/Remotes.hs
+++ b/Remotes.hs
@@ -28,6 +28,7 @@ import System.Directory
import System.Posix.Directory
import List
import Maybe
+import Monad (when, unless)
import Types
import qualified GitRepo as Git
@@ -65,9 +66,9 @@ keyPossibilities key = do
let cheap = filter (not . Git.repoIsUrl) allremotes
let expensive = filter Git.repoIsUrl allremotes
doexpensive <- filterM cachedUUID expensive
- if (not $ null doexpensive)
- then Core.showNote $ "getting UUID for " ++ (list doexpensive) ++ "..."
- else return ()
+ unless (null doexpensive) $ do
+ Core.showNote $ "getting UUID for " ++
+ (list doexpensive) ++ "..."
let todo = cheap ++ doexpensive
if (not $ null todo)
then do
diff --git a/UUID.hs b/UUID.hs
index 79b2b55fa..f2235e4b6 100644
--- a/UUID.hs
+++ b/UUID.hs
@@ -63,10 +63,7 @@ getUUID r = do
where
uncached r = Git.configGet r "annex.uuid" ""
cached r g = Git.configGet g (cachekey r) ""
- updatecache g r u = do
- if (g /= r)
- then setConfig (cachekey r) u
- else return ()
+ updatecache g r u = when (g /= r) $ setConfig (cachekey r) u
cachekey r = "remote." ++ (Git.repoRemoteName r) ++ ".annex-uuid"
{- Make sure that the repo has an annex.uuid setting. -}
@@ -74,11 +71,9 @@ prepUUID :: Annex ()
prepUUID = do
g <- Annex.gitRepo
u <- getUUID g
- if ("" == u)
- then do
- uuid <- liftIO $ genUUID
- setConfig configkey uuid
- else return ()
+ when ("" == u) $ do
+ uuid <- liftIO $ genUUID
+ setConfig configkey uuid
{- Changes a git config setting in both internal state and .git/config -}
setConfig :: String -> String -> Annex ()
@@ -88,7 +83,6 @@ setConfig key value = do
-- re-read git config and update the repo's state
g' <- liftIO $ Git.configRead g
Annex.gitRepoChange g'
- return ()
{- Filters a list of repos to ones that have listed UUIDs. -}
reposByUUID :: [Git.Repo] -> [UUID] -> Annex [Git.Repo]
diff --git a/git-annex.hs b/git-annex.hs
index e9e7ff027..5011fade2 100644
--- a/git-annex.hs
+++ b/git-annex.hs
@@ -8,6 +8,7 @@
import IO (try)
import System.IO
import System.Environment
+import Monad
import qualified Annex
import Types
@@ -42,12 +43,8 @@ tryRun' state errnum (a:as) = do
tryRun' state (errnum + 1) as
Right (True,state') -> tryRun' state' errnum as
Right (False,state') -> tryRun' state' (errnum + 1) as
-tryRun' state errnum [] = do
- if (errnum > 0)
- then error $ (show errnum) ++ " failed"
- else return ()
+tryRun' state errnum [] =
+ when (errnum > 0) $ error $ (show errnum) ++ " failed"
{- Exception pretty-printing. -}
-showErr e = do
- hPutStrLn stderr $ "git-annex: " ++ (show e)
- return ()
+showErr e = hPutStrLn stderr $ "git-annex: " ++ (show e)