git-remote-annex: support importrree=yes remotes

When exporttree=yes is also set. Probably it would also be possible to
support ones with only importtree=yes, by enabling exporttree=yes for
the remote only when using git-remote-annex, but let's keep this
simple... I'm not sure what gets recorded in .git/annex/ state
differently in the two cases that might cause a problem when doing that.

Note that the full annex:: urls generated and displayed for such a
remote omit the importree=yes. Which is ok, cloning from such an url
uses an exporttree=remote, but the git-annex branch doesn't get written
by this program, so once the real config is available from the git-annex
branch, it will still function as an importree=yes remote.
This commit is contained in:
Joey Hess 2024-05-27 12:35:42 -04:00
parent 126d188812
commit e64add7cdf
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 32 additions and 11 deletions

View file

@ -87,12 +87,20 @@ remoteList' autoinit = do
{- Generates a Remote. -}
remoteGen :: M.Map UUID RemoteConfig -> RemoteType -> Git.Repo -> Annex (Maybe Remote)
remoteGen m t g = do
remoteGen = remoteGen' id
remoteGen'
:: (RemoteConfig -> RemoteConfig)
-> M.Map UUID RemoteConfig
-> RemoteType
-> Git.Repo
-> Annex (Maybe Remote)
remoteGen' adjustconfig m t g = do
u <- getRepoUUID g
gc <- Annex.getRemoteGitConfig g
let cu = fromMaybe u $ remoteAnnexConfigUUID gc
let rs = RemoteStateHandle cu
let c = fromMaybe M.empty $ M.lookup cu m
let c = adjustconfig (fromMaybe M.empty $ M.lookup cu m)
generate t g u c gc rs >>= \case
Nothing -> return Nothing
Just r -> Just <$> adjustExportImport (adjustReadOnly (addHooks r)) rs