Fix a potential failure to parse git config

Git has an obnoxious special case in git config, a line "foo" is the same
as "foo = true". That means there is no way to examine the output of
git config and tell if it was run with --null or not, since a "foo"
in the first line could be such a boolean, or could be followed by its
value on the next line if --null were used.

So, rather than trying to do such a detection, track the style of config
at all the points where it's generated.
This commit is contained in:
Joey Hess 2020-04-13 13:05:41 -04:00
parent fbd78cff64
commit ca9c6c5f60
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 31 additions and 32 deletions

View file

@ -222,18 +222,18 @@ tryScan r
Nothing -> return $ Just r
| otherwise = liftIO $ safely $ Git.Config.read r
where
pipedconfig pcmd params = liftIO $ safely $
pipedconfig st pcmd params = liftIO $ safely $
withHandle StdoutHandle createProcessSuccess p $
Git.Config.hRead r
Git.Config.hRead r st
where
p = proc pcmd $ toCommand params
configlist = Ssh.onRemote NoConsumeStdin r
(pipedconfig, return Nothing) "configlist" [] []
(pipedconfig Git.Config.ConfigList, return Nothing) "configlist" [] []
manualconfiglist = do
gc <- Annex.getRemoteGitConfig r
(sshcmd, sshparams) <- Ssh.toRepo NoConsumeStdin r gc remotecmd
liftIO $ pipedconfig sshcmd sshparams
liftIO $ pipedconfig Git.Config.ConfigNullList sshcmd sshparams
where
remotecmd = "sh -c " ++ shellEscape
(cddir ++ " && " ++ "git config --null --list")