summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-06 04:02:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-06 04:06:13 -0400
commitdf21cbfdd2b7342c206ebd4aea32d989328374dc (patch)
tree24f6624e4e4c6dc06b53735bfb52973366e7b159 /Remote.hs
parent0a36f92a31196451c2d838fd0ae15527e8bbce18 (diff)
look up --to and --from remote names only once
This will speed up commands like move and drop.
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/Remote.hs b/Remote.hs
index 8046175d2..3f60ca3ac 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -94,14 +94,15 @@ enabledRemoteList = filterM (repoNotIgnored . repo) =<< remoteList
remoteMap :: Annex (M.Map UUID String)
remoteMap = M.fromList . map (\r -> (uuid r, name r)) <$> remoteList
-{- Looks up a remote by name. (Or by UUID.) Only finds currently configured
- - git remotes. -}
-byName :: String -> Annex (Remote)
-byName n = do
+{- When a name is specified, looks up the remote matching that name.
+ - (Or it can be a UUID.) Only finds currently configured git remotes. -}
+byName :: Maybe String -> Annex (Maybe Remote)
+byName Nothing = return Nothing
+byName (Just n) = do
res <- byName' n
case res of
Left e -> error e
- Right r -> return r
+ Right r -> return $ Just r
byName' :: String -> Annex (Either String Remote)
byName' "" = return $ Left "no remote specified"
byName' n = do