From afe9e78401f7842a41bc353b27036baa2e3046c2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 26 Nov 2011 12:03:01 -0400 Subject: error handling cleanup Use Control.Exception bracket_; want to catch all errors. System.Posix.Env.getEnv doesn't fail, no need to try it. --- Git.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Git.hs') diff --git a/Git.hs b/Git.hs index ba5d831fe..5bdd4afd4 100644 --- a/Git.hs +++ b/Git.hs @@ -72,7 +72,7 @@ module Git ( import System.Posix.Directory import System.Posix.User -import IO (bracket_, try) +import Control.Exception (bracket_) import qualified Data.Map as M hiding (map, split) import Network.URI import Data.Char @@ -438,12 +438,12 @@ reap = do - index file. -} useIndex :: FilePath -> IO (IO ()) useIndex index = do - res <- try $ getEnv var + res <- getEnv var setEnv var index True return $ reset res where var = "GIT_INDEX_FILE" - reset (Right (Just v)) = setEnv var v True + reset (Just v) = setEnv var v True reset _ = unsetEnv var {- Runs an action that causes a git subcommand to emit a sha, and strips @@ -484,10 +484,8 @@ configRead repo@(Repo { location = Dir d }) = do {- Cannot use pipeRead because it relies on the config having been already read. Instead, chdir to the repo. -} cwd <- getCurrentDirectory - bracket_ (changeWorkingDirectory d) - (\_ -> changeWorkingDirectory cwd) $ - pOpen ReadFromPipe "git" ["config", "--list"] $ - hConfigRead repo + bracket_ (changeWorkingDirectory d) (changeWorkingDirectory cwd) $ + pOpen ReadFromPipe "git" ["config", "--list"] $ hConfigRead repo configRead r = assertLocal r $ error "internal" {- Reads git config from a handle and populates a repo with it. -} -- cgit v1.2.3