summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
Diffstat (limited to 'Git')
-rw-r--r--Git/Config.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/Git/Config.hs b/Git/Config.hs
index 5f0e3fdc2..1fe948499 100644
--- a/Git/Config.hs
+++ b/Git/Config.hs
@@ -33,7 +33,8 @@ read repo@(Repo { location = Dir d }) = do
been already read. Instead, chdir to the repo. -}
cwd <- getCurrentDirectory
bracket_ (changeWorkingDirectory d) (changeWorkingDirectory cwd) $
- pOpen ReadFromPipe "git" ["config", "--list"] $ hRead repo
+ pOpen ReadFromPipe "git" ["config", "--null", "--list"] $
+ hRead repo
read r = assertLocal r $ error "internal"
{- Reads git config from a handle and populates a repo with it. -}
@@ -51,8 +52,15 @@ store s repo = do
rs <- Git.Construct.fromRemotes repo'
return $ repo' { remotes = rs }
-{- Parses git config --list output into a config map. -}
+{- Parses git config --list or git config --null --list output into a
+ - config map. -}
parse :: String -> M.Map String String
-parse s = M.fromList $ map pair $ lines s
+parse [] = M.empty
+parse s
+ -- --list output will have an = in the first line
+ | '=' `elem` head ls = M.fromList $ map (separate (== '=')) ls
+ -- --null --list output separates keys from values with newlines
+ | otherwise = M.fromList $ map (separate (== '\n')) $ split "\0" s
where
pair = separate (== '=')
+ ls = lines s