summaryrefslogtreecommitdiff
path: root/Remote/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-31 04:50:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-31 04:50:39 -0400
commitf0957426c586610d16ad9694e002b73324baa29a (patch)
tree2d0d05a82cd6e77e4bb70a26a9f3aa35c9d20a4f /Remote/Git.hs
parent25e4b116c7ab436492a86236f796310d405517a1 (diff)
skip local remotes that are not available (ie, not mounted)
With --fast, unavailable local remotes are filtered out of the fast set. This way, if there are local remotes, --fast always acts only on them, and if none are mounted, acts on nothing. This consistency is better than --fast acting on different remotes depending on what's mounted.
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r--Remote/Git.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs
index e790d01a7..b9d9966a4 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -5,7 +5,7 @@
- Licensed under the GNU GPL version 3 or higher.
-}
-module Remote.Git (remote) where
+module Remote.Git (remote, repoAvail) where
import Control.Exception.Extensible
import qualified Data.Map as M
@@ -164,6 +164,13 @@ inAnnex r key
dispatch (Right Nothing) = unknown
unknown = Left $ "unable to check " ++ Git.repoDescribe r
+{- Checks inexpensively if a repository is available for use. -}
+repoAvail :: Git.Repo -> Annex Bool
+repoAvail r
+ | Git.repoIsHttp r = return True
+ | Git.repoIsUrl r = return True
+ | otherwise = liftIO $ catchBoolIO $ onLocal r $ return True
+
{- Runs an action on a local repository inexpensively, by making an annex
- monad using that repository. -}
onLocal :: Git.Repo -> Annex a -> IO a