diff options
author | Joey Hess <joeyh@joeyh.name> | 2018-01-09 15:36:56 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2018-01-09 16:22:07 -0400 |
commit | aff377f1fd40d1d5dbfc44e9a3ca37e646c1dcd4 (patch) | |
tree | ca6311b6565f217b1b037c7096d82c791cf010b9 /CmdLine | |
parent | 008fe331573e259960c268e4bd30eb0c851dafb7 (diff) |
Improve startup time for commands that do not operate on remotes
And for tab completion, by not unnessessarily statting paths to remotes,
which used to cause eg, spin-up of removable drives.
Got rid of the remotes member of Git.Repo. This was a bit painful.
Remote.Git modifies the list of remotes as it reads their configs,
so still need a persistent list of remotes. So, put it in as
Annex.gitremotes. It's only populated by getGitRemotes, so commands
like examinekey that don't care about remotes won't do so.
This commit was sponsored by Jake Vosloo on Patreon.
Diffstat (limited to 'CmdLine')
-rw-r--r-- | CmdLine/GitAnnex/Options.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs index 04f24367c..d762f6a00 100644 --- a/CmdLine/GitAnnex/Options.hs +++ b/CmdLine/GitAnnex/Options.hs @@ -1,6 +1,6 @@ {- git-annex command-line option parsing - - - Copyright 2010-2017 Joey Hess <id@joeyh.name> + - Copyright 2010-2018 Joey Hess <id@joeyh.name> - - Licensed under the GNU GPL version 3 or higher. -} @@ -10,10 +10,12 @@ module CmdLine.GitAnnex.Options where import Options.Applicative import Options.Applicative.Builder.Internal import Control.Concurrent +import qualified Data.Map as M import Annex.Common import qualified Git.Config import qualified Git.Construct +import Git.Remote import Git.Types import Types.Key import Types.TrustLevel @@ -348,9 +350,10 @@ completeRemotes :: HasCompleter f => Mod f a completeRemotes = completer $ mkCompleter $ \input -> do r <- maybe (pure Nothing) (Just <$$> Git.Config.read) =<< Git.Construct.fromCwd - return $ filter (input `isPrefixOf`) - (maybe [] (mapMaybe remoteName . remotes) r) - + return $ filter (input `isPrefixOf`) $ + map remoteKeyToRemoteName $ + filter isRemoteKey $ + maybe [] (M.keys . config) r completeBackends :: HasCompleter f => Mod f a completeBackends = completeWith $ |