diff --git a/Command/Map.hs b/Command/Map.hs index ae8a694043..15ca5e1496 100644 --- a/Command/Map.hs +++ b/Command/Map.hs @@ -203,7 +203,7 @@ tryScan r liftIO $ pipedconfig "ssh" sshparams where sshcmd = cddir ++ " && " ++ - "git config --list" + "git config --null --list" dir = Git.workTree r cddir | "/~" `isPrefixOf` dir = diff --git a/Git/Config.hs b/Git/Config.hs index 5f0e3fdc21..1fe9484992 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 diff --git a/Remote/Git.hs b/Remote/Git.hs index f27d170840..e527fa4fee 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -111,7 +111,7 @@ tryGitConfigRead r withTempFile "git-annex.tmp" $ \tmpfile h -> do hPutStr h s hClose h - pOpen ReadFromPipe "git" ["config", "--list", "--file", tmpfile] $ + pOpen ReadFromPipe "git" ["config", "--null", "--list", "--file", tmpfile] $ Git.Config.hRead r store a = do diff --git a/debian/changelog b/debian/changelog index 5fc01f9ead..3c977e817d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ git-annex (3.20111212) UNRELEASED; urgency=low * Union merge now finds the least expensive way to represent the merge. * reinject: Add a sanity check for using an annexed file as the source file. + * Properly handle multiline git config values. -- Joey Hess Mon, 12 Dec 2011 01:57:49 -0400