diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-15 12:46:04 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-15 12:48:27 -0400 |
commit | 09cd04277577381464eddceb42558ad300c49378 (patch) | |
tree | 25413673497e639331c81fd0864b5ef0e394078a | |
parent | ef28b3fef7e236d8c27ce35308c0e37ece58d20c (diff) |
Properly handle multiline git config values.
A crash on parsing was fixed a while ago. This adds support for fully
correctly parsing multiline git config values, using git config --null.
Since git-annex-shell configlist uses normal git config output, I left in
support for that too; the two forms of config output can be easily
identified by the parser. Since configlist only prints the annex.uuid
config, there's no risk of multiline values there, so no need to change it.
-rw-r--r-- | Command/Map.hs | 2 | ||||
-rw-r--r-- | Git/Config.hs | 14 | ||||
-rw-r--r-- | Remote/Git.hs | 2 | ||||
-rw-r--r-- | debian/changelog | 1 |
4 files changed, 14 insertions, 5 deletions
diff --git a/Command/Map.hs b/Command/Map.hs index ae8a69404..15ca5e149 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 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 diff --git a/Remote/Git.hs b/Remote/Git.hs index f27d17084..e527fa4fe 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 5fc01f9ea..3c977e817 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 <joeyh@debian.org> Mon, 12 Dec 2011 01:57:49 -0400 |