From 633021e135b9abe3ad5a5abe9f346bc5675949dd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 9 Mar 2019 13:21:49 -0400 Subject: [PATCH] --no-push and remote.name.annex-push prevent exporting trees to special remotes Users may want sync to only export, or only import and this is broadly analagous to push and pull, so it makes sense to use the same configuration for it. --- Assistant/Threads/Exporter.hs | 2 +- CHANGELOG | 2 ++ Command/Sync.hs | 22 ++++++++++++++-------- doc/git-annex-sync.mdwn | 7 ++++--- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Assistant/Threads/Exporter.hs b/Assistant/Threads/Exporter.hs index 983c46747e..ab0da5b128 100644 --- a/Assistant/Threads/Exporter.hs +++ b/Assistant/Threads/Exporter.hs @@ -64,7 +64,7 @@ exportToRemotes rs = do forM rs $ \r -> do Annex.changeState $ \st -> st { Annex.errcounter = 0 } start <- liftIO getCurrentTime - void $ Command.Sync.seekExportContent rs + void $ Command.Sync.seekExportContent Nothing rs =<< getCurrentBranch -- Look at command error counter to see if the export -- didn't work. diff --git a/CHANGELOG b/CHANGELOG index 00652a6e7f..e2d0b11dc3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,8 @@ git-annex (7.20190220) UNRELEASED; urgency=medium themselves. * Remote tracking branches are updated when importing and exporting to special remotes, in ways analagous to how git fetch and git push do. + * sync, assistant: --no-push and remote.name.annex-push prevent exporting + trees to special remotes. * Fix storage of metadata values containing newlines. (Reversion introduced in version 7.20190122.) * Sped up git-annex export in repositories with lots of keys. diff --git a/Command/Sync.hs b/Command/Sync.hs index 8c886b2cb0..9663101f39 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -49,6 +49,7 @@ import Annex.Content import Command.Get (getKey') import qualified Command.Move import qualified Command.Export +import qualified Command.Import import Annex.Drop import Annex.UUID import Logs.UUID @@ -191,8 +192,10 @@ seek o = allowConcurrentOutput $ do -- Send content to any exports first, in -- case that lets content be dropped from -- other repositories. - exportedcontent <- withbranch $ seekExportContent exportremotes - syncedcontent <- withbranch $ seekSyncContent o dataremotes + exportedcontent <- withbranch $ + seekExportContent (Just o) exportremotes + syncedcontent <- withbranch $ + seekSyncContent o dataremotes -- Transferring content can take a while, -- and other changes can be pushed to the -- git-annex branch on the remotes in the @@ -687,13 +690,16 @@ syncFile ebloom rs af k = onlyActionOn' k $ do - - Returns True if any file transfers were made. -} -seekExportContent :: [Remote] -> CurrBranch -> Annex Bool -seekExportContent rs (currbranch, _) = or <$> forM rs go +seekExportContent :: Maybe SyncOptions -> [Remote] -> CurrBranch -> Annex Bool +seekExportContent o rs (currbranch, _) = or <$> forM rs go where - go r = bracket - (Export.openDb (Remote.uuid r)) - Export.closeDb - (\db -> Export.writeLockDbWhile db (go' r db)) + go r + | not (maybe True pullOption o) = return False + | not (remoteAnnexPush (Remote.gitconfig r)) = return False + | otherwise = bracket + (Export.openDb (Remote.uuid r)) + Export.closeDb + (\db -> Export.writeLockDbWhile db (go' r db)) go' r db = do (exported, mtbcommitsha) <- case remoteAnnexTrackingBranch (Remote.gitconfig r) of Nothing -> nontracking r diff --git a/doc/git-annex-sync.mdwn b/doc/git-annex-sync.mdwn index a61de8c6a7..83969408c6 100644 --- a/doc/git-annex-sync.mdwn +++ b/doc/git-annex-sync.mdwn @@ -51,7 +51,8 @@ by running "git annex sync" on the remote. * `--pull`, `--no-pull` - By default, git pulls from remotes. Use --no-pull to disable all pulling. + By default, git pulls from remotes and imports from some special remotes. + Use --no-pull to disable all pulling. When `remote..annex-pull` or `remote..annex-sync` are set to false, pulling is disabled for those remotes, and using @@ -59,8 +60,8 @@ by running "git annex sync" on the remote. * `--push`, `--no-push` - By default, git pushes changes to remotes. - Use --no-push to disable all pushing. + By default, git pushes changes to remotes and exports to some + special remotes. Use --no-push to disable all pushing. When `remote..annex-push` or `remote..annex-sync` are set to false, or `remote..annex-readonly` is set to true,