summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-23 20:06:02 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-23 20:06:02 -0400
commit22c77acb85aa7dffa52d28f7ff84b64b75f5b621 (patch)
tree631d1c390cafa5e49ecb02c491dec1de06b46bf6 /Remote
parentd4343da8277a208e1a3eaed10e1a9f5096bfcd39 (diff)
Detect when the remote is broken like bitbucket is, and exits 0 when it fails to run git-annex-shell.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Git.hs33
1 files changed, 20 insertions, 13 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 4110c1491..752d70d23 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -136,21 +136,14 @@ guardUsable r onerr a
- returns the updated repo. -}
tryGitConfigRead :: Git.Repo -> Annex Git.Repo
tryGitConfigRead r
- | not $ M.null $ Git.config r = return r -- already read
+ | haveconfig r = return r -- already read
| Git.repoIsSsh r = store $ do
v <- onRemote r (pipedsshconfig, Left undefined) "configlist" [] []
- case (v, Git.remoteName r) of
- (Right r', _) -> return r'
- (Left _, Just n) -> do
- {- Is this remote just not available, or does
- - it not have git-annex-shell?
- - Find out by trying to fetch from the remote. -}
- whenM (inRepo $ Git.Command.runBool [Param "fetch", Param "--quiet", Param n]) $ do
- let k = "remote." ++ n ++ ".annex-ignore"
- warning $ "Remote " ++ n ++ " does not have git-annex installed; setting " ++ k
- inRepo $ Git.Command.run [Param "config", Param k, Param "true"]
- return r
- _ -> return r
+ case v of
+ Right r'
+ | haveconfig r' -> return r'
+ | otherwise -> configlist_failed
+ Left _ -> configlist_failed
| Git.repoIsHttp r = do
headers <- getHttpHeaders
store $ safely $ geturlconfig headers
@@ -159,6 +152,8 @@ tryGitConfigRead r
ensureInitialized
Annex.getState Annex.repo
where
+ haveconfig = not . M.null . Git.config
+
-- Reading config can fail due to IO error or
-- for other reasons; catch all possible exceptions.
safely a = either (const $ return r) return
@@ -200,6 +195,18 @@ tryGitConfigRead r
| otherwise =
old : exchange ls new
+ {- Is this remote just not available, or does
+ - it not have git-annex-shell?
+ - Find out by trying to fetch from the remote. -}
+ configlist_failed = case Git.remoteName r of
+ Nothing -> return r
+ Just n -> do
+ whenM (inRepo $ Git.Command.runBool [Param "fetch", Param "--quiet", Param n]) $ do
+ let k = "remote." ++ n ++ ".annex-ignore"
+ warning $ "Remote " ++ n ++ " does not have git-annex installed; setting " ++ k
+ inRepo $ Git.Command.run [Param "config", Param k, Param "true"]
+ return r
+
{- Checks if a given remote has the content for a key inAnnex.
- If the remote cannot be accessed, or if it cannot determine
- whether it has the content, returns a Left error message.