Allow --trust etc to specify a repository by name, for temporarily trusting repositories that are not configured remotes.
This commit is contained in:
parent
66f5b390fe
commit
f547277b75
3 changed files with 26 additions and 8 deletions
29
Remote.hs
29
Remote.hs
|
@ -34,7 +34,7 @@ module Remote (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.State (liftIO)
|
import Control.Monad.State (liftIO)
|
||||||
import Control.Monad (when, liftM, filterM)
|
import Control.Monad (filterM)
|
||||||
import Data.List
|
import Data.List
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
@ -91,20 +91,35 @@ genList = do
|
||||||
|
|
||||||
{- Looks up a remote by name. (Or by UUID.) -}
|
{- Looks up a remote by name. (Or by UUID.) -}
|
||||||
byName :: String -> Annex (Remote Annex)
|
byName :: String -> Annex (Remote Annex)
|
||||||
byName "" = error "no remote specified"
|
|
||||||
byName n = do
|
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
|
allremotes <- genList
|
||||||
let match = filter matching allremotes
|
let match = filter matching allremotes
|
||||||
when (null match) $ error $
|
if (null match)
|
||||||
"there is no git remote named \"" ++ n ++ "\""
|
then return $ Left $ "there is no git remote named \"" ++ n ++ "\""
|
||||||
return $ head match
|
else return $ Right $ head match
|
||||||
where
|
where
|
||||||
matching r = n == name r || n == uuid r
|
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 :: String -> Annex UUID
|
||||||
nameToUUID "." = getUUID =<< Annex.gitRepo -- special case for current repo
|
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. -}
|
{- Filters a list of remotes to ones that have the listed uuids. -}
|
||||||
remotesWithUUID :: [Remote Annex] -> [UUID] -> [Remote Annex]
|
remotesWithUUID :: [Remote Annex] -> [UUID] -> [Remote Annex]
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -4,6 +4,8 @@ git-annex (0.20110611) UNRELEASED; urgency=low
|
||||||
cp is still used when copying file from repos on the same filesystem,
|
cp is still used when copying file from repos on the same filesystem,
|
||||||
since --reflink=auto can make it significantly faster on filesystems
|
since --reflink=auto can make it significantly faster on filesystems
|
||||||
such as btrfs.
|
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
|
-- Joey Hess <joeyh@debian.org> Mon, 13 Jun 2011 19:53:24 -0400
|
||||||
|
|
||||||
|
|
|
@ -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.
|
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
|
* --backend=name
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue