aboutsummaryrefslogtreecommitdiff
path: root/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-26 12:03:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-26 12:03:01 -0400
commitafe9e78401f7842a41bc353b27036baa2e3046c2 (patch)
tree96e99d386325443c70d914eda4779ef55de6a2a5 /Git.hs
parentaf239e5c3312592f2d3445cc9970baa890022a5e (diff)
error handling cleanup
Use Control.Exception bracket_; want to catch all errors. System.Posix.Env.getEnv doesn't fail, no need to try it.
Diffstat (limited to 'Git.hs')
-rw-r--r--Git.hs12
1 files changed, 5 insertions, 7 deletions
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. -}