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
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2010-12-31 00:08:22 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
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
|
2019-12-02 14:57:09 +00:00
|
|
|
import Git.Types
|
2013-09-24 21:25:47 +00:00
|
|
|
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
|
remove dead nodes when loading the cluster log
This is to avoid inserting a cluster uuid into the location log when
only dead nodes in the cluster contain the content of a key.
One reason why this is necessary is Remote.keyLocations, which excludes
dead repositories from the list. But there are probably many more.
Implementing this was challenging, because Logs.Location importing
Logs.Cluster which imports Logs.Trust which imports Remote.List resulted
in an import cycle through several other modules.
Resorted to making Logs.Location not import Logs.Cluster, and instead
it assumes that Annex.clusters gets populated when necessary before it's
called.
That's done in Annex.Startup, which is run by the git-annex command
(but not other commands) at early startup in initialized repos. Or,
is run after initialization.
Note that is Remote.Git, it is unable to import Annex.Startup, because
Remote.Git importing Logs.Cluster leads the the same import cycle.
So ensureInitialized is not passed annexStartup in there.
Other commands, like git-annex-shell currently don't run annexStartup
either.
So there are cases where Logs.Location will not see clusters. So it won't add
any cluster UUIDs when loading the log. That's ok, the only reason to do
that is to make display of where objects are located include clusters,
and to make commands like git-annex get --from treat keys as being located
in a cluster. git-annex-shell certainly does not do anything like that,
and I'm pretty sure Remote.Git (and callers to Remote.Git.onLocalRepo)
don't either.
2024-06-16 18:35:07 +00:00
|
|
|
import Annex.Startup
|
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
|
2018-10-01 18:12:06 +00:00
|
|
|
seek = withNothing (commandAction 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
|
2019-12-02 14:57:09 +00:00
|
|
|
showConfig configkeyUUID $ fromUUID u
|
2019-12-05 18:36:43 +00:00
|
|
|
showConfig coreGCryptId . fromConfigValue
|
2019-12-02 14:57:09 +00:00
|
|
|
=<< fromRepo (Git.Config.get coreGCryptId mempty)
|
2011-05-15 06:02:46 +00:00
|
|
|
stop
|
2013-09-24 21:25:47 +00:00
|
|
|
where
|
2019-12-02 14:57:09 +00:00
|
|
|
showConfig k v = liftIO $ putStrLn $ fromConfigKey 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
|
remove dead nodes when loading the cluster log
This is to avoid inserting a cluster uuid into the location log when
only dead nodes in the cluster contain the content of a key.
One reason why this is necessary is Remote.keyLocations, which excludes
dead repositories from the list. But there are probably many more.
Implementing this was challenging, because Logs.Location importing
Logs.Cluster which imports Logs.Trust which imports Remote.List resulted
in an import cycle through several other modules.
Resorted to making Logs.Location not import Logs.Cluster, and instead
it assumes that Annex.clusters gets populated when necessary before it's
called.
That's done in Annex.Startup, which is run by the git-annex command
(but not other commands) at early startup in initialized repos. Or,
is run after initialization.
Note that is Remote.Git, it is unable to import Annex.Startup, because
Remote.Git importing Logs.Cluster leads the the same import cycle.
So ensureInitialized is not passed annexStartup in there.
Other commands, like git-annex-shell currently don't run annexStartup
either.
So there are cases where Logs.Location will not see clusters. So it won't add
any cluster UUIDs when loading the log. That's ok, the only reason to do
that is to make display of where objects are located include clusters,
and to make commands like git-annex get --from treat keys as being located
in a cluster. git-annex-shell certainly does not do anything like that,
and I'm pretty sure Remote.Git (and callers to Remote.Git.onLocalRepo)
don't either.
2024-06-16 18:35:07 +00:00
|
|
|
initialize startupAnnex Nothing Nothing
|
2014-03-26 18:22:21 +00:00
|
|
|
getUUID
|
|
|
|
, return NoUUID
|
|
|
|
)
|