git-annex-shell: Make configlist automatically initialize a remote git repository, as long as a git-annex branch has been pushed to it, to simplify setup of remote git repositories, including via gitolite.

This commit is contained in:
Joey Hess 2014-03-26 14:22:21 -04:00
parent cb7574ce10
commit 72978a8de0
3 changed files with 28 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{- git-annex command {- git-annex command
- -
- Copyright 2010 Joey Hess <joey@kitenet.net> - Copyright 2010-2014 Joey Hess <joey@kitenet.net>
- -
- Licensed under the GNU GPL version 3 or higher. - Licensed under the GNU GPL version 3 or higher.
-} -}
@ -10,6 +10,8 @@ module Command.ConfigList where
import Common.Annex import Common.Annex
import Command import Command
import Annex.UUID import Annex.UUID
import Annex.Init
import qualified Annex.Branch
import qualified Git.Config import qualified Git.Config
import Remote.GCrypt (coreGCryptId) import Remote.GCrypt (coreGCryptId)
@ -22,9 +24,23 @@ seek = withNothing start
start :: CommandStart start :: CommandStart
start = do start = do
u <- getUUID u <- findOrGenUUID
showConfig "annex.uuid" $ fromUUID u showConfig "annex.uuid" $ fromUUID u
showConfig coreGCryptId =<< fromRepo (Git.Config.get coreGCryptId "") showConfig coreGCryptId =<< fromRepo (Git.Config.get coreGCryptId "")
stop stop
where where
showConfig k v = liftIO $ putStrLn $ k ++ "=" ++ v showConfig k v = liftIO $ putStrLn $ k ++ "=" ++ v
{- The repository may not yet have a UUID; automatically initialize it
- when there's a git-annex branch available. -}
findOrGenUUID :: Annex UUID
findOrGenUUID = do
u <- getUUID
if u /= NoUUID
then return u
else ifM Annex.Branch.hasSibling
( do
initialize Nothing
getUUID
, return NoUUID
)

4
debian/changelog vendored
View file

@ -15,6 +15,10 @@ git-annex (5.20140321) UNRELEASED; urgency=medium
* forget --drop-dead: Avoid removing the dead remote from the trust.log, * forget --drop-dead: Avoid removing the dead remote from the trust.log,
so that if git remotes for it still exist anywhere, git annex info so that if git remotes for it still exist anywhere, git annex info
will still know it's dead and not show it. will still know it's dead and not show it.
* git-annex-shell: Make configlist automatically initialize
a remote git repository, as long as a git-annex branch has
been pushed to it, to simplify setup of remote git repositories,
including via gitolite.
-- Joey Hess <joeyh@debian.org> Fri, 21 Mar 2014 14:08:41 -0400 -- Joey Hess <joeyh@debian.org> Fri, 21 Mar 2014 14:08:41 -0400

View file

@ -26,7 +26,12 @@ first "/~/" or "/~user/" is expanded to the specified home directory.
* configlist directory * configlist directory
This outputs a subset of the git configuration, in the same form as This outputs a subset of the git configuration, in the same form as
`git config --list` `git config --list`. This is used to get the annex.uuid of the remote
repository.
When run in a repository that does not yet have an annex.uuid, one
will be created, as long as a git-annex branch has already been pushed to
the repository.
* inannex directory [key ...] * inannex directory [key ...]