make remoteKeyToRemoteName safer

If it's passed a ConfigKey such as annex.version, avoid returning
an empty remote name and return Nothing instead. Also, foo.bar.baz is
not treated as a remote named "bar".
This commit is contained in:
Joey Hess 2021-04-23 13:28:23 -04:00
parent 5cb05c43c9
commit 0e830b6bb5
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 20 additions and 14 deletions

View file

@ -61,7 +61,7 @@ import qualified Data.Map as M
findSpecialRemotes :: String -> Annex [Git.Repo]
findSpecialRemotes s = do
m <- fromRepo Git.config
liftIO $ mapM construct $ remotepairs m
liftIO $ catMaybes <$> mapM construct (remotepairs m)
where
remotepairs = M.toList . M.filterWithKey match
construct (k,_) = Git.Construct.remoteNamedFromKey k