diff --git a/Remote.hs b/Remote.hs index 5fc6d1c009..0f31b99b29 100644 --- a/Remote.hs +++ b/Remote.hs @@ -37,6 +37,7 @@ module Remote ( keyPossibilities, keyPossibilitiesTrusted, nameToUUID, + nameToUUID', showTriedRemotes, showLocations, forceTrust, @@ -48,7 +49,6 @@ module Remote ( import qualified Data.Map as M import Text.JSON import Text.JSON.Generic -import Data.Tuple import Data.Ord import Common.Annex @@ -121,23 +121,25 @@ noRemoteUUIDMsg r = "cannot determine uuid for " ++ name r - and returns its UUID. Finds even repositories that are not - configured in .git/config. -} nameToUUID :: RemoteName -> Annex UUID -nameToUUID "." = getUUID -- special case for current repo -nameToUUID "here" = getUUID -nameToUUID "" = error "no remote specified" -nameToUUID n = byName' n >>= go +nameToUUID = either error return <=< nameToUUID' + +nameToUUID' :: RemoteName -> Annex (Either String UUID) +nameToUUID' "." = Right <$> getUUID -- special case for current repo +nameToUUID' "here" = Right <$> getUUID +nameToUUID' n = byName' n >>= go where - go (Right r) = case uuid r of - NoUUID -> error $ noRemoteUUIDMsg r - u -> return u - go (Left e) = fromMaybe (error e) <$> bydescription - bydescription = do + go (Right r) = return $ case uuid r of + NoUUID -> Left $ noRemoteUUIDMsg r + u -> Right u + go (Left e) = do m <- uuidMap - case M.lookup n $ transform swap m of - Just u -> return $ Just u - Nothing -> return $ byuuid m - byuuid m = M.lookup (toUUID n) $ transform double m - transform a = M.fromList . map a . M.toList - double (a, _) = (a, a) + return $ case M.keys (M.filter (== n) m) of + [u] -> Right u + [] -> let u = toUUID n + in case M.keys (M.filterWithKey (\k _ -> k == u) m) of + [] -> Left e + _ -> Right u + _us -> Left "Found multiple repositories with that description" {- Pretty-prints a list of UUIDs of remotes, for human display. - diff --git a/debian/changelog b/debian/changelog index 86e0fae391..85cb72cde1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,10 @@ git-annex (5.20140307) UNRELEASED; urgency=medium * webapp: Use securemem for constant time auth token comparisons. * copy --fast --to remote: Avoid printing anything for files that are already believed to be present on the remote. + * Commands that allow specifying which repository to act on using + the repository's description will now fail when multiple repositories + match, rather than picking a repository at random. + (So will --in=) -- Joey Hess Thu, 06 Mar 2014 16:17:01 -0400 diff --git a/doc/bugs/git_annex_dead_does_not_work_as_expected_when_multiple_repos_exist_with_the_same_name___40__notably_including_dead_ones__41__.mdwn b/doc/bugs/git_annex_dead_does_not_work_as_expected_when_multiple_repos_exist_with_the_same_name___40__notably_including_dead_ones__41__.mdwn index 7e26f63dfe..72a0c9cc3a 100644 --- a/doc/bugs/git_annex_dead_does_not_work_as_expected_when_multiple_repos_exist_with_the_same_name___40__notably_including_dead_ones__41__.mdwn +++ b/doc/bugs/git_annex_dead_does_not_work_as_expected_when_multiple_repos_exist_with_the_same_name___40__notably_including_dead_ones__41__.mdwn @@ -40,3 +40,5 @@ Now, git annex dead somecopy will randomly (based on the order of the UUIDs?) ch ### What version of git-annex are you using? On what operating system? git-annex 4.20131024 on linux. Also occurs on OSX. + +> [[fixed|done]] --[[Joey]]