2010-12-31 00:08:22 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2010-2014 Joey Hess <id@joeyh.name>
|
2010-12-31 00:08:22 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.ConfigList where
|
|
|
|
|
|
|
|
import Command
|
2011-10-15 21:47:03 +00:00
|
|
|
import Annex.UUID
|
2014-03-26 18:22:21 +00:00
|
|
|
import Annex.Init
|
|
|
|
import qualified Annex.Branch
|
2013-09-24 21:25:47 +00:00
|
|
|
import qualified Git.Config
|
|
|
|
import Remote.GCrypt (coreGCryptId)
|
2015-08-05 17:49:54 +00:00
|
|
|
import qualified CmdLine.GitAnnexShell.Fields as Fields
|
2015-08-05 18:09:25 +00:00
|
|
|
import CmdLine.GitAnnexShell.Checks
|
2010-12-31 00:08:22 +00:00
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2015-08-05 17:49:54 +00:00
|
|
|
cmd = noCommit $ dontCheck repoExists $
|
2015-07-08 19:08:02 +00:00
|
|
|
command "configlist" SectionPlumbing
|
|
|
|
"outputs relevant git configuration"
|
|
|
|
paramNothing (withParams seek)
|
2010-12-31 00:08:22 +00:00
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
seek :: CmdParams -> CommandSeek
|
fix inversion of control in CommandSeek (no behavior changes)
I've been disliking how the command seek actions were written for some
time, with their inversion of control and ugly workarounds.
The last straw to fix it was sync --content, which didn't fit the
Annex [CommandStart] interface well at all. I have not yet made it take
advantage of the changed interface though.
The crucial change, and probably why I didn't do it this way from the
beginning, is to make each CommandStart action be run with exceptions
caught, and if it fails, increment a failure counter in annex state.
So I finally remove the very first code I wrote for git-annex, which
was before I had exception handling in the Annex monad, and so ran outside
that monad, passing state explicitly as it ran each CommandStart action.
This was a real slog from 1 to 5 am.
Test suite passes.
Memory usage is lower than before, sometimes by a couple of megabytes, and
remains constant, even when running in a large repo, and even when
repeatedly failing and incrementing the error counter. So no accidental
laziness space leaks.
Wall clock speed is identical, even in large repos.
This commit was sponsored by an anonymous bitcoiner.
2014-01-20 08:11:42 +00:00
|
|
|
seek = withNothing start
|
2010-12-31 00:08:22 +00:00
|
|
|
|
2011-09-15 20:50:49 +00:00
|
|
|
start :: CommandStart
|
2010-12-31 00:08:22 +00:00
|
|
|
start = do
|
2014-03-26 18:22:21 +00:00
|
|
|
u <- findOrGenUUID
|
2013-09-24 21:25:47 +00:00
|
|
|
showConfig "annex.uuid" $ fromUUID u
|
|
|
|
showConfig coreGCryptId =<< fromRepo (Git.Config.get coreGCryptId "")
|
2011-05-15 06:02:46 +00:00
|
|
|
stop
|
2013-09-24 21:25:47 +00:00
|
|
|
where
|
2014-10-09 18:53:13 +00:00
|
|
|
showConfig k v = liftIO $ putStrLn $ k ++ "=" ++ v
|
2014-03-26 18:22:21 +00:00
|
|
|
|
|
|
|
{- The repository may not yet have a UUID; automatically initialize it
|
2015-08-05 17:49:54 +00:00
|
|
|
- when there's a git-annex branch available or if the autoinit field was
|
|
|
|
- set. -}
|
2014-03-26 18:22:21 +00:00
|
|
|
findOrGenUUID :: Annex UUID
|
|
|
|
findOrGenUUID = do
|
|
|
|
u <- getUUID
|
|
|
|
if u /= NoUUID
|
|
|
|
then return u
|
2015-08-05 17:49:54 +00:00
|
|
|
else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit))
|
2014-03-26 18:22:21 +00:00
|
|
|
( do
|
2015-08-05 18:09:25 +00:00
|
|
|
liftIO checkNotReadOnly
|
2017-12-13 18:34:32 +00:00
|
|
|
initialize (AutoInit True) Nothing Nothing
|
2014-03-26 18:22:21 +00:00
|
|
|
getUUID
|
|
|
|
, return NoUUID
|
|
|
|
)
|