diff options
author | 2014-03-17 15:44:42 -0400 | |
---|---|---|
committer | 2014-03-17 15:44:42 -0400 | |
commit | 25a87b4bcd8dc775694f909819e74a959e6a2451 (patch) | |
tree | ecddf466da57f318fd1316a3642922a7a7987118 | |
parent | 4ecf97060824849cd8c20aad10b05eda31824188 (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.
-rw-r--r-- | Command/Map.hs | 19 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/bugs/map_error_after_forget.mdwn | 2 |
3 files changed, 15 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' diff --git a/debian/changelog b/debian/changelog index d4224d5a3..3cb751eec 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,8 @@ git-annex (5.20140307) UNRELEASED; urgency=medium * groupwanted can be used in preferred content expressions. * metadata: Add --get * metadata: Support --key option (and some other ones like --all) + * 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. -- Joey Hess <joeyh@debian.org> Thu, 06 Mar 2014 16:17:01 -0400 diff --git a/doc/bugs/map_error_after_forget.mdwn b/doc/bugs/map_error_after_forget.mdwn index 6eb9d85ca..b4531ad59 100644 --- a/doc/bugs/map_error_after_forget.mdwn +++ b/doc/bugs/map_error_after_forget.mdwn @@ -33,3 +33,5 @@ git-annex: user error (git ["config","--null","--list"] exited 126) failed git-annex: map: 1 failed """]] + +> [[fixed|done]] --[[Joey]] |