git clone support for git-remote-annex
Also support using annex:: urls that specify the whole special remote config. Both of these cases need a special remote to be initialized enough to use it, which means writing to .git/config but not to the git-annex branch. When cloning, the remote is left set up in .git/config, so further use of it, by git-annex or git-remote-annex will work. When using git with an annex:: url, a temporary remote is written to .git/config, but then removed at the end. While that's a little bit ugly, the fact is that the Remote interface expects that it's ok to set git configs of the remote that is being initialized. And it's nowhere near as ugly as the alternative of making a temporary git repository and initializing the special remote in there. Cloning from a repository that does not contain a git-annex branch and then later running git-annex init is currently broken, although I've gotten most of the way there to supporting it. See cleanupInitialization FIXME. Special shout out to git clone for running gitremote-helpers with GIT_DIR set, but not in the git repository and with GIT_WORK_TREE not set. Resulting in needing the fixupRepo hack. Sponsored-by: unqueued on Patreon
This commit is contained in:
parent
df5011ec43
commit
59fc2005ec
4 changed files with 196 additions and 45 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex repository initialization
|
||||
-
|
||||
- Copyright 2011-2022 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2011-2024 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -12,6 +12,7 @@ module Annex.Init (
|
|||
checkInitializeAllowed,
|
||||
ensureInitialized,
|
||||
autoInitialize,
|
||||
autoInitialize',
|
||||
isInitialized,
|
||||
initialize,
|
||||
initialize',
|
||||
|
@ -256,10 +257,13 @@ guardSafeToUseRepo a = ifM (inRepo Git.Config.checkRepoConfigInaccessible)
|
|||
- Checks repository version and handles upgrades too.
|
||||
-}
|
||||
autoInitialize :: Annex [Remote] -> Annex ()
|
||||
autoInitialize remotelist = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
autoInitialize = autoInitialize' autoInitializeAllowed
|
||||
|
||||
autoInitialize' :: Annex Bool -> Annex [Remote] -> Annex ()
|
||||
autoInitialize' check remotelist = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
where
|
||||
needsinit =
|
||||
whenM (initializeAllowed <&&> autoInitializeAllowed) $ do
|
||||
whenM (initializeAllowed <&&> check) $ do
|
||||
initialize Nothing Nothing
|
||||
autoEnableSpecialRemotes remotelist
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue