From ddf05c271b150f5c5311fa7a68fbbadf03faba80 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 13 May 2024 14:35:17 -0400 Subject: [PATCH] fix cloning from an annex:: remote with exporttree=yes Updating the remote list needs the config to be written to the git-annex branch, which was not done for good reasons. While it would be possible to instead use Remote.List.remoteGen without writing to the branch, I already have a plan to discard git-annex branch writes made by git-remote-annex, so the simplest fix is to write the config to the branch. Sponsored-by: k0ld on Patreon --- CmdLine/GitRemoteAnnex.hs | 10 +++------- doc/todo/git-remote-annex.mdwn | 9 ++++++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CmdLine/GitRemoteAnnex.hs b/CmdLine/GitRemoteAnnex.hs index 000f2ae5a8..e21128e7fd 100644 --- a/CmdLine/GitRemoteAnnex.hs +++ b/CmdLine/GitRemoteAnnex.hs @@ -22,6 +22,7 @@ import qualified Git.Remote.Remove import qualified Annex.SpecialRemote as SpecialRemote import qualified Annex.Branch import qualified Types.Remote as Remote +import qualified Logs.Remote import Annex.Transfer import Backend.GitRemoteAnnex import Config @@ -481,20 +482,15 @@ withSpecialRemote cfg@(SpecialRemoteConfig {}) sab a = case specialRemoteName cf where -- Initialize a new special remote with the provided configuration -- and name. - -- - -- The configuration is not stored in the git-annex branch, because - -- it's expected that the git repository stored on the special - -- remote includes its configuration, perhaps under a different - -- name, and perhaps slightly different (when the annex:: url - -- omitted some unimportant part of the configuration). initremote remotename = do let c = M.insert SpecialRemote.nameField (Proposed remotename) (specialRemoteConfig cfg) t <- either giveup return (SpecialRemote.findType c) dummycfg <- liftIO dummyRemoteGitConfig - (c', _u) <- Remote.setup t Remote.Init (Just (specialRemoteUUID cfg)) + (c', u) <- Remote.setup t Remote.Init (Just (specialRemoteUUID cfg)) Nothing c dummycfg `onException` cleanupremote remotename + Logs.Remote.configSet u c' setConfig (remoteConfig c' "url") (specialRemoteUrl cfg) remotesChanged getEnabledSpecialRemoteByName remotename >>= \case diff --git a/doc/todo/git-remote-annex.mdwn b/doc/todo/git-remote-annex.mdwn index 96b5fcd994..7683eff17d 100644 --- a/doc/todo/git-remote-annex.mdwn +++ b/doc/todo/git-remote-annex.mdwn @@ -14,9 +14,6 @@ This is implememented and working. Remaining todo list for it: * Test incremental pushes that don't fast-forward. -* exporttree=yes remote works, but cloning one from the annex:: url - does not, somehow exportTree is not set then. - * Support max-bundles config * Need to mention git-remote-annex in special remotes page, and perhaps @@ -91,6 +88,12 @@ This is implememented and working. Remaining todo list for it: This should be fixable by making git-remote-annex not write to the git-annex branch, but to eg, a temporary journal directory. + Also, cloning currently writes the special remote config into remote.log, + which might be slightly different in some way than the config in + remote.log for the same remote. cloning should not change the stored + config of a remote, but that branch write was necessary. So throwing + away the branch write is also good for this case. + Also, when the remote uses importree=yes, pushing to it updates content identifiers, which currently get recorded in the git-annex branch. It would be good to avoid that being written as well.