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 /Annex.hs | |
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 'Annex.hs')
-rw-r--r-- | Annex.hs | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,6 +1,6 @@ {- git-annex monad - - - Copyright 2010-2013 Joey Hess <id@joeyh.name> + - Copyright 2010-2018 Joey Hess <id@joeyh.name> - - Licensed under the GNU GPL version 3 or higher. -} @@ -34,12 +34,14 @@ module Annex ( getRemoteGitConfig, withCurrentState, changeDirectory, + getGitRemotes, incError, ) where import Common import qualified Git import qualified Git.Config +import qualified Git.Construct import Annex.Fixup import Git.CatFile import Git.HashObject @@ -98,6 +100,7 @@ data AnnexState = AnnexState { repo :: Git.Repo , repoadjustment :: (Git.Repo -> IO Git.Repo) , gitconfig :: GitConfig + , gitremotes :: Maybe [Git.Repo] , backend :: Maybe (BackendA Annex) , remotes :: [Types.Remote.RemoteA Annex] , remoteannexstate :: M.Map UUID AnnexState @@ -153,6 +156,7 @@ newState c r = do { repo = r , repoadjustment = return , gitconfig = c + , gitremotes = Nothing , backend = Nothing , remotes = [] , remoteannexstate = M.empty @@ -357,3 +361,13 @@ incError = changeState $ \s -> let ! c = errcounter s + 1 ! s' = s { errcounter = c } in s' + +getGitRemotes :: Annex [Git.Repo] +getGitRemotes = do + s <- getState id + case gitremotes s of + Just rs -> return rs + Nothing -> do + rs <- liftIO $ Git.Construct.fromRemotes (repo s) + changeState $ \s' -> s' { gitremotes = Just rs } + return rs |