summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-09-30 02:23:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-09-30 02:23:24 -0400
commita7e7dda55a82cb5007c5eaa2f7752f5cefdcb1d2 (patch)
tree4e65ff613ae755c4eeb01113b750ba449afd1272 /Remote.hs
parentc86a2f686aa447d1cf30cecaa2feedaf0e2c6ba2 (diff)
Fix referring to remotes by uuid.
I think that I broke this in some fairly recent refactoring.
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Remote.hs b/Remote.hs
index 0ce01872a..05f70a5d7 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -87,7 +87,8 @@ genList = do
u <- getUUID r
generate t r u (M.lookup u m)
-{- Looks up a remote by name. (Or by UUID.) -}
+{- Looks up a remote by name. (Or by UUID.) Only finds currently configured
+ - git remotes. -}
byName :: String -> Annex (Remote Annex)
byName n = do
res <- byName' n
@@ -106,7 +107,8 @@ byName' n = do
matching r = n == name r || n == uuid r
{- Looks up a remote by name (or by UUID, or even by description),
- - and returns its UUID. -}
+ - and returns its UUID. Finds even remotes that are not configured in
+ - .git/config. -}
nameToUUID :: String -> Annex UUID
nameToUUID "." = getUUID =<< Annex.gitRepo -- special case for current repo
nameToUUID n = do
@@ -115,7 +117,11 @@ nameToUUID n = do
Left e -> fromMaybe (error e) <$> byDescription
Right r -> return $ uuid r
where
- byDescription = M.lookup n . invertMap <$> uuidMap
+ byDescription = do
+ m <- uuidMap
+ case M.lookup n $ invertMap m of
+ Just u -> return $ Just u
+ Nothing -> return $ M.lookup n m
invertMap = M.fromList . map swap . M.toList
swap (a, b) = (b, a)