--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.
This commit is contained in:
Joey Hess 2019-03-09 13:21:49 -04:00
parent d9ee048d85
commit 633021e135
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 21 additions and 12 deletions

View file

@ -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.

View file

@ -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.

View file

@ -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

View file

@ -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.<name>.annex-pull` or `remote.<name>.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.<name>.annex-push` or `remote.<name>.annex-sync` are
set to false, or `remote.<name>.annex-readonly` is set to true,