aboutsummaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-14 11:42:51 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-14 11:42:51 -0400
commit92a4af8b2019de2fac6df9c1e92e3858fe644639 (patch)
tree281b17d88737fe3b2155100f28b34f00cb99395c /Git
parent1f66af2b53432802ad4a3a0f5a3b4f3863cd00ad (diff)
avoid unnecessary chdir
Diffstat (limited to 'Git')
-rw-r--r--Git/Config.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/Git/Config.hs b/Git/Config.hs
index 55ab8a6f1..0d73a0b9a 100644
--- a/Git/Config.hs
+++ b/Git/Config.hs
@@ -30,8 +30,11 @@ read 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", "--null", "--list"] $
+ if dirContains d cwd
+ then go
+ else bracket_ (changeWorkingDirectory d) (changeWorkingDirectory cwd) go
+ where
+ go = pOpen ReadFromPipe "git" ["config", "--null", "--list"] $
hRead repo
read r = assertLocal r $
error $ "internal error; trying to read config of " ++ show r