diff options
author | Joey Hess <joey@kitenet.net> | 2012-03-16 01:59:07 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-03-16 01:59:07 -0400 |
commit | 184a69171d5d983ee2f08cce28011d235f44cc5c (patch) | |
tree | ff85fc620618b55c8cbed0d8c99212e73004f5b5 /Git/Config.hs | |
parent | c0c9991c9f5322aef05f4c97d2c3f3bdc3101e46 (diff) |
removed another 10 lines via ifM
Diffstat (limited to 'Git/Config.hs')
-rw-r--r-- | Git/Config.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Git/Config.hs b/Git/Config.hs index 0d73a0b9a..8190a62ad 100644 --- a/Git/Config.hs +++ b/Git/Config.hs @@ -26,16 +26,15 @@ getMaybe key repo = M.lookup key (config repo) {- Runs git config and populates a repo with its config. -} read :: Repo -> IO Repo -read repo@(Repo { location = Dir d }) = do +read repo@(Repo { location = Dir d }) = bracketcd d $ {- Cannot use pipeRead because it relies on the config having been already read. Instead, chdir to the repo. -} - cwd <- getCurrentDirectory - if dirContains d cwd - then go - else bracket_ (changeWorkingDirectory d) (changeWorkingDirectory cwd) go + pOpen ReadFromPipe "git" ["config", "--null", "--list"] $ hRead repo where - go = pOpen ReadFromPipe "git" ["config", "--null", "--list"] $ - hRead repo + bracketcd to a = bracketcd' to a =<< getCurrentDirectory + bracketcd' to a cwd + | dirContains to cwd = a + | otherwise = bracket_ (changeWorkingDirectory to) (changeWorkingDirectory cwd) a read r = assertLocal r $ error $ "internal error; trying to read config of " ++ show r |