aboutsummaryrefslogtreecommitdiff
path: root/Command/Map.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-17 15:44:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-17 15:44:42 -0400
commit25a87b4bcd8dc775694f909819e74a959e6a2451 (patch)
treeecddf466da57f318fd1316a3642922a7a7987118 /Command/Map.hs
parent4ecf97060824849cd8c20aad10b05eda31824188 (diff)
map: Fix crash when one of the remotes of a repo is a local directory that does not exist, or is not a git repo.
Diffstat (limited to 'Command/Map.hs')
-rw-r--r--Command/Map.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/Command/Map.hs b/Command/Map.hs
index 9b80d2035..7c11fb2ef 100644
--- a/Command/Map.hs
+++ b/Command/Map.hs
@@ -158,7 +158,8 @@ absRepo reference r
| Git.repoIsUrl r = return r
| otherwise = liftIO $ do
r' <- Git.Construct.fromAbsPath =<< absPath (Git.repoPath r)
- flip Annex.eval Annex.gitRepo =<< Annex.new r'
+ r'' <- safely $ flip Annex.eval Annex.gitRepo =<< Annex.new r'
+ return (fromMaybe r' r'')
{- Checks if two repos are the same. -}
same :: Git.Repo -> Git.Repo -> Bool
@@ -192,14 +193,9 @@ tryScan :: Git.Repo -> Annex (Maybe Git.Repo)
tryScan r
| Git.repoIsSsh r = sshscan
| Git.repoIsUrl r = return Nothing
- | otherwise = safely $ Git.Config.read r
+ | otherwise = liftIO $ safely $ Git.Config.read r
where
- safely a = do
- result <- liftIO (try a :: IO (Either SomeException Git.Repo))
- case result of
- Left _ -> return Nothing
- Right r' -> return $ Just r'
- pipedconfig cmd params = safely $
+ pipedconfig cmd params = liftIO $ safely $
withHandle StdoutHandle createProcessSuccess p $
Git.Config.hRead r
where
@@ -247,3 +243,10 @@ combineSame = map snd . nubBy sameuuid . map pair
where
sameuuid (u1, _) (u2, _) = u1 == u2 && u1 /= NoUUID
pair r = (getUncachedUUID r, r)
+
+safely :: IO Git.Repo -> IO (Maybe Git.Repo)
+safely a = do
+ result <- try a :: IO (Either SomeException Git.Repo)
+ case result of
+ Left _ -> return Nothing
+ Right r' -> return $ Just r'