aboutsummaryrefslogtreecommitdiff
path: root/Remotes.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-03 17:21:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-03 17:21:00 -0400
commit657395b628b46b378eda77d5dc6edcdde7183b38 (patch)
tree2f7bc67fbed23214568feefe0c2c1292092eb0d9 /Remotes.hs
parent1de12a291891463c6d532a10c74cbda1872c8b9b (diff)
add describe subcommand
Diffstat (limited to 'Remotes.hs')
-rw-r--r--Remotes.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/Remotes.hs b/Remotes.hs
index 4dcc4c9ad..a7d6be67d 100644
--- a/Remotes.hs
+++ b/Remotes.hs
@@ -211,17 +211,23 @@ repoNotIgnored r = do
same :: Git.Repo -> Git.Repo -> Bool
same a b = Git.repoRemoteName a == Git.repoRemoteName b
-{- Looks up a remote by name. -}
+{- Looks up a remote by name. (Or by UUID.) -}
byName :: String -> Annex Git.Repo
byName "." = Annex.gitRepo -- special case to refer to current repository
byName name = do
when (null name) $ error "no remote specified"
g <- Annex.gitRepo
- let match = filter (\r -> Just name == Git.repoRemoteName r) $
- Git.remotes g
+ match <- filterM matching $ Git.remotes g
when (null match) $ error $
"there is no git remote named \"" ++ name ++ "\""
return $ head match
+ where
+ matching r = do
+ if Just name == Git.repoRemoteName r
+ then return True
+ else do
+ u <- getUUID r
+ return $ (name == u)
{- Tries to copy a key's content from a remote's annex to a file. -}
copyFromRemote :: Git.Repo -> Key -> FilePath -> Annex Bool