From 93a4f3d4e6970b05116fc25b8d57f0dd9d9ec675 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 21 May 2011 11:52:13 -0400 Subject: [PATCH] Add --debug option. Closes: #627499 This takes advantage of the debug logging done by missingh, and I added my own debug messages for executeFile calls. There are still some other low-level ways git-annex runs stuff that are not shown by debugging, but this gets most of it easily. --- Options.hs | 7 ++++++- Remote/Hook.hs | 2 +- RsyncFile.hs | 1 - Utility.hs | 12 +++++++++++- debian/changelog | 1 + doc/git-annex.mdwn | 4 ++++ 6 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Options.hs b/Options.hs index ae5707e4a0..f8dbfb6bc0 100644 --- a/Options.hs +++ b/Options.hs @@ -8,6 +8,8 @@ module Options where import System.Console.GetOpt +import System.Log.Logger +import Control.Monad.State (liftIO) import qualified Annex import Types @@ -27,7 +29,9 @@ commonOptions = , Option ['q'] ["quiet"] (NoArg (setquiet True)) "avoid verbose output" , Option ['v'] ["verbose"] (NoArg (setquiet False)) - "allow verbose output" + "allow verbose output (default)" + , Option ['d'] ["debug"] (NoArg (setdebug)) + "show debug messages" , Option ['b'] ["backend"] (ReqArg setforcebackend paramName) "specify key-value backend to use" ] @@ -36,3 +40,4 @@ commonOptions = setfast v = Annex.changeState $ \s -> s { Annex.fast = v } setquiet v = Annex.changeState $ \s -> s { Annex.quiet = v } setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v } + setdebug = liftIO $ updateGlobalLogger "" $ setLevel DEBUG diff --git a/Remote/Hook.hs b/Remote/Hook.hs index 7f2d5dbee2..dc4d392741 100644 --- a/Remote/Hook.hs +++ b/Remote/Hook.hs @@ -12,7 +12,7 @@ import Control.Exception.Extensible (IOException) import qualified Data.Map as M import Control.Monad.State (liftIO) import System.FilePath -import System.Posix.Process +import System.Posix.Process hiding (executeFile) import System.Posix.IO import System.IO import System.IO.Error (try) diff --git a/RsyncFile.hs b/RsyncFile.hs index afff46c0ce..48d927fcf2 100644 --- a/RsyncFile.hs +++ b/RsyncFile.hs @@ -7,7 +7,6 @@ module RsyncFile where -import System.Posix.Process import Data.String.Utils import Utility diff --git a/Utility.hs b/Utility.hs index 816464373b..47d10ed759 100644 --- a/Utility.hs +++ b/Utility.hs @@ -17,6 +17,7 @@ module Utility ( relPathDirToFile, boolSystem, boolSystemEnv, + executeFile, shellEscape, shellUnEscape, unsetFileMode, @@ -39,7 +40,8 @@ module Utility ( import System.IO import System.Exit -import System.Posix.Process +import qualified System.Posix.Process +import System.Posix.Process hiding (executeFile) import System.Posix.Signals import System.Posix.Files import System.Posix.Types @@ -52,6 +54,7 @@ import Foreign (complement) import Data.List import Data.Maybe import Control.Monad (liftM2, when, unless) +import System.Log.Logger {- A type for parameters passed to a shell command. A command can - be passed either some Params (multiple parameters can be included, @@ -104,6 +107,13 @@ boolSystemEnv command params env = do restoresignals oldint oldset executeFile command True (toCommand params) env +{- executeFile with debug logging -} +executeFile :: FilePath -> Bool -> [String] -> Maybe [(String, String)] -> IO a +executeFile c path p e = do + debugM "Utility.executeFile" $ + "Running: " ++ c ++ " " ++ show p ++ " " ++ maybe "" show e + System.Posix.Process.executeFile c path p e + {- Escapes a filename or other parameter to be safely able to be exposed to - the shell. -} shellEscape :: String -> String diff --git a/debian/changelog b/debian/changelog index f8b5f02cf2..16821c848d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ git-annex (0.20110517) UNRELEASED; urgency=low * status: New subcommand to show info about an annex, including its size. * --backend now overrides any backend configured in .gitattributes files. + * Add --debug option. Closes: #627499 -- Joey Hess Mon, 16 May 2011 20:27:46 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index e2a04d27b9..7f2fce9d23 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -330,6 +330,10 @@ Many git-annex commands will stage changes for later `git commit` by you. Enable verbose logging. +* --debug + + Show debug messages. + * --from=repository Specifies a repository that content will be retrieved from, or that