summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-07 16:34:12 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-07 16:34:12 -0400
commit3c263cc9ea7fe5dc5b07db4a66281cda752fc6b3 (patch)
treee964b31258cd6085fed337cdad7182f17e174ec3
parent64bc4e4751c5738d3e6c44db9452c46b26245910 (diff)
fix
-rw-r--r--Remote.hs18
1 files changed, 8 insertions, 10 deletions
diff --git a/Remote.hs b/Remote.hs
index d4fbf36cf..1591512ef 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -107,21 +107,19 @@ byName' n = do
- .git/config. -}
nameToUUID :: String -> Annex UUID
nameToUUID "." = getUUID -- special case for current repo
-nameToUUID n = do
- res <- byName' n
- case res of
- Left e -> fromMaybe (error e) <$> byDescription
- Right r -> return $ uuid r
+nameToUUID n = byName' n >>= go
where
- byDescription = do
+ go (Right r) = return $ uuid r
+ go (Left e) = fromMaybe (error e) <$> bydescription
+ bydescription = do
m <- uuidMap
- case M.lookup wantuuid $ transform swap m of
+ case M.lookup n $ transform swap m of
Just u -> return $ Just u
- Nothing -> return $ M.lookup wantuuid $ transform double m
+ Nothing -> return $ byuuid m
+ byuuid m = M.lookup (read n) $ transform double m
transform a = M.fromList . map a . M.toList
swap (a, b) = (b, a)
- double (a, _) = (show a, a)
- wantuuid = read n
+ double (a, _) = (a, a)
{- Pretty-prints a list of UUIDs of remotes, for human display.
-