diff options
author | 2011-06-13 22:19:44 -0400 | |
---|---|---|
committer | 2011-06-13 22:19:44 -0400 | |
commit | f547277b751d81f516a638bc281735fa1946b17d (patch) | |
tree | 6c17f7ae514409e953bb74309478c74c04c7c3ba | |
parent | 66f5b390fe761946280c8999648d13e917fba45b (diff) |
Allow --trust etc to specify a repository by name, for temporarily trusting repositories that are not configured remotes.
-rw-r--r-- | Remote.hs | 29 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 3 |
3 files changed, 26 insertions, 8 deletions
@@ -34,7 +34,7 @@ module Remote ( ) where import Control.Monad.State (liftIO) -import Control.Monad (when, liftM, filterM) +import Control.Monad (filterM) import Data.List import qualified Data.Map as M import Data.Maybe @@ -91,20 +91,35 @@ genList = do {- Looks up a remote by name. (Or by UUID.) -} byName :: String -> Annex (Remote Annex) -byName "" = error "no remote specified" byName n = do + res <- byName' n + case res of + Left e -> error e + Right r -> return r +byName' :: String -> Annex (Either String (Remote Annex)) +byName' "" = return $ Left "no remote specified" +byName' n = do allremotes <- genList let match = filter matching allremotes - when (null match) $ error $ - "there is no git remote named \"" ++ n ++ "\"" - return $ head match + if (null match) + then return $ Left $ "there is no git remote named \"" ++ n ++ "\"" + else return $ Right $ head match where matching r = n == name r || n == uuid r -{- Looks up a remote by name (or by UUID), and returns its UUID. -} +{- Looks up a remote by name (or by UUID, or even by description), + - and returns its UUID. -} nameToUUID :: String -> Annex UUID nameToUUID "." = getUUID =<< Annex.gitRepo -- special case for current repo -nameToUUID n = liftM uuid (byName n) +nameToUUID n = do + res <- byName' n + case res of + Left e -> return . (maybe (error e) id) =<< byDescription + Right r -> return $ uuid r + where + byDescription = return . M.lookup n . invertMap =<< uuidMap + invertMap = M.fromList . map swap . M.toList + swap (a, b) = (b, a) {- Filters a list of remotes to ones that have the listed uuids. -} remotesWithUUID :: [Remote Annex] -> [UUID] -> [Remote Annex] diff --git a/debian/changelog b/debian/changelog index 0837a9f34..de012de5b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ git-annex (0.20110611) UNRELEASED; urgency=low cp is still used when copying file from repos on the same filesystem, since --reflink=auto can make it significantly faster on filesystems such as btrfs. + * Allow --trust etc to specify a repository by name, for temporarily + trusting repositories that are not configured remotes. -- Joey Hess <joeyh@debian.org> Mon, 13 Jun 2011 19:53:24 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 25f053af6..12756d802 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -365,7 +365,8 @@ Many git-annex commands will stage changes for later `git commit` by you. Overrides trust settings for a repository. May be specified more than once. - The repository should be specified using the name of a configured remote. + The repository should be specified using the name of a configured remote, + or the UUID or description of a repository. * --backend=name |