avoid unnecessary chdir

This commit is contained in:
Joey Hess 2012-01-14 11:42:51 -04:00
parent 1f66af2b53
commit 92a4af8b20

View file

@ -30,8 +30,11 @@ read repo@(Repo { location = Dir d }) = do
{- Cannot use pipeRead because it relies on the config having {- Cannot use pipeRead because it relies on the config having
been already read. Instead, chdir to the repo. -} been already read. Instead, chdir to the repo. -}
cwd <- getCurrentDirectory cwd <- getCurrentDirectory
bracket_ (changeWorkingDirectory d) (changeWorkingDirectory cwd) $ if dirContains d cwd
pOpen ReadFromPipe "git" ["config", "--null", "--list"] $ then go
else bracket_ (changeWorkingDirectory d) (changeWorkingDirectory cwd) go
where
go = pOpen ReadFromPipe "git" ["config", "--null", "--list"] $
hRead repo hRead repo
read r = assertLocal r $ read r = assertLocal r $
error $ "internal error; trying to read config of " ++ show r error $ "internal error; trying to read config of " ++ show r