From 92a4af8b2019de2fac6df9c1e92e3858fe644639 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 14 Jan 2012 11:42:51 -0400 Subject: [PATCH] avoid unnecessary chdir --- Git/Config.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Git/Config.hs b/Git/Config.hs index 55ab8a6f15..0d73a0b9a5 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