add git config debugging

(and process cwd debugging)

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2023-05-15 15:35:29 -04:00
parent ee23c540ea
commit 0da0e2efcc
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 46 additions and 9 deletions

View file

@ -104,19 +104,23 @@ global = do
hRead :: Repo -> ConfigStyle -> Handle -> IO Repo
hRead repo st h = do
val <- S.hGetContents h
store val st repo
let c = parse val st
debug (DebugSource "Git.Config") $ "git config read: " ++
show (map (\(k, v) -> (show k, map show v)) (M.toList c))
storeParsed c repo
{- Stores a git config into a Repo, returning the new version of the Repo.
- The git config may be multiple lines, or a single line.
- Config settings can be updated incrementally.
-}
store :: S.ByteString -> ConfigStyle -> Repo -> IO Repo
store s st repo = do
let c = parse s st
updateLocation $ repo
{ config = (M.map Prelude.head c) `M.union` config repo
, fullconfig = M.unionWith (++) c (fullconfig repo)
}
store s st = storeParsed (parse s st)
storeParsed :: M.Map ConfigKey [ConfigValue] -> Repo -> IO Repo
storeParsed c repo = updateLocation $ repo
{ config = (M.map Prelude.head c) `M.union` config repo
, fullconfig = M.unionWith (++) c (fullconfig repo)
}
{- Stores a single config setting in a Repo, returning the new version of
- the Repo. Config settings can be updated incrementally. -}

View file

@ -189,11 +189,13 @@ withCreateProcess p action = bracket (createProcess p) cleanupProcess
debugProcess :: CreateProcess -> ProcessHandle -> IO ()
debugProcess p h = do
pid <- getPid h
debug "Utility.Process" $ unwords
debug "Utility.Process" $ unwords $
[ describePid pid
, action ++ ":"
, showCmd p
]
] ++ case cwd p of
Nothing -> []
Just c -> ["in", show c]
where
action
| piped (std_in p) && piped (std_out p) = "chat"

View file

@ -36,3 +36,10 @@ originally in some older 8.2022 but now in 10.20230407
[[!meta author=yoh]]
[[!tag projects/datalad]]
> Hard to know when there is *enough* debugging, but with what I've added,
> I can't think of any more I could add that would help with a problem of
> this kind. Unless of course git-annex has a deep dark bug where it reads
> an annex.uuid from git config, but then somehow misplaces it. But I can't
> imagine such a bug so it's hard to add debugging for it. So, I suppose
> this is [[done]] --[[Joey]]

View file

@ -0,0 +1,24 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2023-05-15T17:43:21Z"
content="""
Something that prevents `git config` from working, or prevents it from
listing an annex.uuid for the remote, seems like the overridingly likely
reason for their problem. (You were asking the right questions
[here](https://github.com/datalad/datalad/issues/7371#issuecomment-1545975295)
and I don't think they really answered them, unless it happened in your office
hours.)
I've made --debug include the output of `git config --list`,
which allows seeing if a problem prevents git from reading the config of
the remote.
I also made the debug output tell what directory it's running a command in
when it's not the pwd.
So, for example:
[2023-05-15 15:16:01.414302245] (Utility.Process) process [59665] read: git ["config","--null","--list"] in "/home/joey/tmp/a"
[2023-05-15 15:16:01.419396816] (Git.Config) git config read: [("",[]),("annex.uuid",["9553f51c-87ad-4321-86fb-de4aa630e997"]) [...]
"""]]