diff --git a/Annex.hs b/Annex.hs index a5a82644be..7ccc0a1f58 100644 --- a/Annex.hs +++ b/Annex.hs @@ -120,6 +120,7 @@ data AnnexRead = AnnexRead , sshstalecleaned :: TMVar Bool , signalactions :: TVar (M.Map SignalAction (Int -> IO ())) , transferrerpool :: TransferrerPool + , debugenabled :: Bool , debugselector :: DebugSelector } @@ -138,6 +139,7 @@ newAnnexRead c = do , sshstalecleaned = sc , signalactions = si , transferrerpool = tp + , debugenabled = annexDebug c , debugselector = debugSelectorFromGitConfig c } diff --git a/Annex/Debug.hs b/Annex/Debug.hs index 4437147302..f3626ffaa1 100644 --- a/Annex/Debug.hs +++ b/Annex/Debug.hs @@ -26,5 +26,6 @@ import Annex.Debug.Utility -- when debugging is not enabled. fastDebug :: DebugSource -> String -> Annex.Annex () fastDebug src msg = do - selector <- Annex.getRead Annex.debugselector - liftIO $ Utility.Debug.fastDebug selector src msg + rd <- Annex.getRead id + when (Annex.debugenabled rd) $ + liftIO $ Utility.Debug.fastDebug (Annex.debugselector rd) src msg diff --git a/CmdLine.hs b/CmdLine.hs index 29b90eecd1..eb75e66e11 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -142,14 +142,14 @@ subCmdName argv = (name, args) | otherwise = (Just a, reverse c ++ as) -- | Note that the GlobalSetter must have already had its annexReadSetter --- applied before entering the Annex monad; that cannot be changed while --- running in the Annex monad. +-- applied before entering the Annex monad to run this; that cannot be +-- changed while running in the Annex monad. prepRunCommand :: Command -> GlobalSetter -> Annex () prepRunCommand cmd globalsetter = do when (cmdnomessages cmd) $ Annex.setOutput QuietOutput annexStateSetter globalsetter - whenM (annexDebug <$> Annex.getGitConfig) $ + whenM (Annex.getRead Annex.debugenabled) $ enableDebugOutput findAddonCommand :: Maybe String -> IO (Maybe Command) diff --git a/CmdLine/Option.hs b/CmdLine/Option.hs index 305ef88dc2..8f31060112 100644 --- a/CmdLine/Option.hs +++ b/CmdLine/Option.hs @@ -45,12 +45,12 @@ commonGlobalOptions = <> help "allow verbose output (default)" <> hidden ) - , globalFlag (setAnnexState $ setdebug True) + , globalFlag (setdebug True) ( long "debug" <> short 'd' <> help "show debug messages" <> hidden ) - , globalFlag (setAnnexState $ setdebug False) + , globalFlag (setdebug False) ( long "no-debug" <> help "don't show debug messages" <> hidden @@ -74,15 +74,17 @@ commonGlobalOptions = setforcebackend v = setAnnexState $ Annex.changeState $ \s -> s { Annex.forcebackend = Just v } - -- Overriding this way, rather than just setting annexDebug - -- makes the config be passed on to any git-annex child processes. - setdebug v = Annex.addGitConfigOverride $ - decodeBS' $ debugconfig <> "=" <> boolConfig' v + setdebug v = mconcat + [ setAnnexRead $ \rd -> rd { Annex.debugenabled = v } + -- Also set in git config so it will be passed on to any + -- git-annex child processes. + , setAnnexState $ Annex.addGitConfigOverride $ + decodeBS' $ debugconfig <> "=" <> boolConfig' v + ] setdebugfilter v = mconcat [ setAnnexRead $ \rd -> rd - { Annex.debugselector = parseDebugSelector v - } + { Annex.debugselector = parseDebugSelector v } -- Also set in git config so it will be passed on to any -- git-annex child processes. , setAnnexState $ Annex.addGitConfigOverride $ diff --git a/Remote/Helper/Ssh.hs b/Remote/Helper/Ssh.hs index 9807a3f80b..270cc700ed 100644 --- a/Remote/Helper/Ssh.hs +++ b/Remote/Helper/Ssh.hs @@ -59,7 +59,7 @@ git_annex_shell cs r command params fields dir = Git.repoPath r shellcmd = "git-annex-shell" getshellopts = do - debugenabled <- annexDebug <$> Annex.getGitConfig + debugenabled <- Annex.getRead Annex.debugenabled let params' = if debugenabled then Param "--debug" : params else params