display explanations in --debug too
authorJoey Hess <joeyh@joeyh.name>
Mon, 31 Jul 2023 17:06:40 +0000 (13:06 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 31 Jul 2023 17:06:40 +0000 (13:06 -0400)
When --explain is not enabled. This can be useful debugging information
as well.

Sponsored-by: Dartmouth College's DANDI project
Annex/Debug.hs
Messages.hs

index f3626ffaa119880be68643a70c44cb0cb5d0b7ce..fb7d7eef77b451850f37384f625fecf592ac5a8a 100644 (file)
@@ -1,6 +1,6 @@
 {- git-annex debugging
  -
- - Copyright 2021 Joey Hess <id@joeyh.name>
+ - Copyright 2021-2023 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -10,6 +10,7 @@ module Annex.Debug (
        DebugSource(..),
        debug,
        fastDebug,
+       fastDebug',
        configureDebug,
        debugSelectorFromGitConfig,
        parseDebugSelector,
@@ -27,5 +28,8 @@ import Annex.Debug.Utility
 fastDebug :: DebugSource -> String -> Annex.Annex ()
 fastDebug src msg = do
        rd <- Annex.getRead id
-       when (Annex.debugenabled rd) $
-               liftIO $ Utility.Debug.fastDebug (Annex.debugselector rd) src msg
+       fastDebug' rd src msg
+
+fastDebug' :: Annex.AnnexRead -> DebugSource -> String -> Annex.Annex ()
+fastDebug' rd src msg = when (Annex.debugenabled rd) $
+       liftIO $ Utility.Debug.fastDebug (Annex.debugselector rd) src msg
index 96c087e91181fcad242b086683e1825073d92a20..3bf1256ee11329f7f81d80e83aae65e135826451 100644 (file)
@@ -303,10 +303,11 @@ jsonOutputEnabled = withMessageState $ \s -> return $
 explain :: ActionItem -> Maybe StringContainingQuotedPath -> Annex ()
 explain ai (Just msg) = do
        rd <- Annex.getRead id
-       when (Annex.explainenabled rd) $
-               let d = actionItemDesc ai
-               in outputMessage JSON.none id $
-                       "[ " <> (if d == mempty then "" else (d <> " ")) <> msg <> " ]\n"
+       let d = actionItemDesc ai
+       let msg' = "[ " <> (if d == mempty then "" else (d <> " ")) <> msg <> " ]\n"
+       if Annex.explainenabled rd
+               then outputMessage JSON.none id msg'
+               else fastDebug' rd "Messages.explain" (decodeBS (noquote msg'))
 explain _ _ = return ()
 
 {- Prevents any concurrent console access while running an action, so