summaryrefslogtreecommitdiff
path: root/Remote/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-15 14:45:27 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-15 14:45:27 -0400
commit98909de6069003c0e1de0cc844855f65fafe3977 (patch)
tree112e59027bc48b5eb02792d945603813b23f43f8 /Remote/Git.hs
parent3af9d1dadeac883bc5631b7f4bbd4bf40246543c (diff)
optimise handling of unavailable repos
The exception handling resulted in git config --list being run twice for unavailable repos. This dials it back down to running it only once.
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r--Remote/Git.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs
index a493d3d68..4498ec907 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -191,10 +191,8 @@ tryGitConfigRead r
| Git.repoIsHttp r = store geturlconfig
| Git.GCrypt.isEncrypted r = handlegcrypt =<< getConfigMaybe (remoteConfig r "uuid")
| Git.repoIsUrl r = return r
- | otherwise = store $ liftIO $
- readlocalannexconfig
- `catchNonAsync` (const $ Git.Config.read r)
- `catchNonAsync` (const $ return r)
+ | otherwise = store $ liftIO $
+ readlocalannexconfig `catchNonAsync` (const $ return r)
where
haveconfig = not . M.null . Git.config
@@ -276,13 +274,14 @@ tryGitConfigRead r
Just v -> store $ liftIO $ setUUID r $
genUUIDInNameSpace gCryptNameSpace v
- {- Throws an exception if the remote is not already initialied
- - or cannot be automatically initialized. -}
+ {- The local repo may not yet be initialized, so try to initialize
+ - it if allowed. However, if that fails, still return the read
+ - git config. -}
readlocalannexconfig = do
s <- Annex.new r
Annex.eval s $ do
Annex.BranchState.disableUpdate
- ensureInitialized
+ void $ tryAnnex $ ensureInitialized
Annex.getState Annex.repo
{- Checks if a given remote has the content for a key inAnnex.