summaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-12 12:47:11 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-12 12:47:11 -0400
commit31b24348d25f5aec7ff521b7452fab6833a1d051 (patch)
tree83fb070ea3ed5e0b4837209e0181270ca3336156 /GitRepo.hs
parente4bc7e599a799d758c4d948dce65a7fa05dd50cb (diff)
new git config read method
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index 565780311..c87bd355e 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -22,9 +22,11 @@ module GitRepo (
import Directory
import System
import System.Directory
+import System.Posix.Directory
import System.Path
import System.Cmd.Utils
import System.IO
+import IO (bracket_)
import System.Posix.Process
import Data.String.Utils
import Data.Map as Map hiding (map, split)
@@ -151,11 +153,17 @@ gitPipeRead repo params = assertlocal repo $ do
ret <- hGetContentsStrict h
return ret
-{- Runs git config and populates a repo with its settings. -}
+{- Runs git config and populates a repo with its config. -}
gitConfigRead :: GitRepo -> IO GitRepo
gitConfigRead repo = assertlocal repo $ do
- c <- gitPipeRead repo ["config", "--list"]
- return repo { config = gitConfigParse c }
+ {- Cannot use gitPipeRead because it relies on the config having
+ been already read. Instead, chdir to the repo. -}
+ cwd <- getCurrentDirectory
+ bracket_ (changeWorkingDirectory (top repo))
+ (\_ -> changeWorkingDirectory cwd) $ do
+ pOpen ReadFromPipe "git" ["config", "--list"] $ \h -> do
+ val <- hGetContentsStrict h
+ return repo { config = gitConfigParse val }
{- Parses git config --list output into a config map. -}
gitConfigParse :: String -> Map.Map String String