summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2018-01-09 15:36:56 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2018-01-09 16:22:07 -0400
commitaff377f1fd40d1d5dbfc44e9a3ca37e646c1dcd4 (patch)
treeca6311b6565f217b1b037c7096d82c791cf010b9 /Remote
parent008fe331573e259960c268e4bd30eb0c851dafb7 (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 'Remote')
-rw-r--r--Remote/GCrypt.hs2
-rw-r--r--Remote/Git.hs13
2 files changed, 7 insertions, 8 deletions
diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs
index 3270a1dc7..52ae5e17a 100644
--- a/Remote/GCrypt.hs
+++ b/Remote/GCrypt.hs
@@ -182,7 +182,7 @@ gCryptSetup _ mu _ c gc = go $ M.lookup "gitrepo" c
(c', _encsetup) <- encryptionSetup c gc
let url = Git.GCrypt.urlPrefix ++ gitrepo
- rs <- fromRepo Git.remotes
+ rs <- Annex.getGitRemotes
case filter (\r -> Git.remoteName r == Just remotename) rs of
[] -> inRepo $ Git.Command.run
[ Param "remote", Param "add"
diff --git a/Remote/Git.hs b/Remote/Git.hs
index da2ecee57..8df14937e 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -78,7 +78,7 @@ remote = RemoteType
list :: Bool -> Annex [Git.Repo]
list autoinit = do
c <- fromRepo Git.config
- rs <- mapM (tweakurl c) =<< fromRepo Git.remotes
+ rs <- mapM (tweakurl c) =<< Annex.getGitRemotes
mapM (configRead autoinit) rs
where
annexurl n = "remote." ++ n ++ ".annexurl"
@@ -104,8 +104,8 @@ gitSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> Remote
gitSetup Init mu _ c _ = do
let location = fromMaybe (giveup "Specify location=url") $
Url.parseURIRelaxed =<< M.lookup "location" c
- g <- Annex.gitRepo
- u <- case filter (\r -> Git.location r == Git.Url location) (Git.remotes g) of
+ rs <- Annex.getGitRemotes
+ u <- case filter (\r -> Git.location r == Git.Url location) rs of
[r] -> getRepoUUID r
[] -> giveup "could not find existing git remote with specified location"
_ -> giveup "found multiple git remotes with specified location"
@@ -263,10 +263,9 @@ tryGitConfigRead autoinit r
return r
store = observe $ \r' -> do
- g <- gitRepo
- let l = Git.remotes g
- let g' = g { Git.remotes = exchange l r' }
- Annex.changeState $ \s -> s { Annex.repo = g' }
+ l <- Annex.getGitRemotes
+ let rs = exchange l r'
+ Annex.changeState $ \s -> s { Annex.gitremotes = Just rs }
exchange [] _ = []
exchange (old:ls) new