diff options
author | Joey Hess <joey@kitenet.net> | 2011-05-21 11:52:13 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-05-21 11:52:13 -0400 |
commit | 93a4f3d4e6970b05116fc25b8d57f0dd9d9ec675 (patch) | |
tree | 27af97e123c3b22f4eb6e19afa7bca6ec9f2891f | |
parent | 1876db50f258a1a6a67d874049e93a84d34cac32 (diff) |
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.
-rw-r--r-- | Options.hs | 7 | ||||
-rw-r--r-- | Remote/Hook.hs | 2 | ||||
-rw-r--r-- | RsyncFile.hs | 1 | ||||
-rw-r--r-- | Utility.hs | 12 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 4 |
6 files changed, 23 insertions, 4 deletions
diff --git a/Options.hs b/Options.hs index ae5707e4a..f8dbfb6bc 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 7f2d5dbee..dc4d39274 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 afff46c0c..48d927fcf 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 816464373..47d10ed75 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 f8b5f02cf..16821c848 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 <joeyh@debian.org> Mon, 16 May 2011 20:27:46 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index e2a04d27b..7f2fce9d2 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 |