From 11025aaa449495db399cd02cafc15cec5923281c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Mar 2017 16:00:06 -0400 Subject: sync --content-of=path For when you want to sync only some files' contents, not the whole working tree. This commit was sponsored by Anthony DeRobertis on Patreon. --- CHANGELOG | 2 ++ Command/Sync.hs | 27 ++++++++++++++++++++-- doc/git-annex-sync.mdwn | 8 +++++++ ...sync_content_of_a_single_directory_or_file.mdwn | 3 +++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ceaa043ca..7c81241bd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,8 @@ git-annex (6.20170301.2) UNRELEASED; urgency=medium * Support GIT_SSH and GIT_SSH_COMMAND, which are handled close the same as they are by git. However, unlike git, git-annex sometimes needs to pass the -n parameter when using these. + * sync --content-of=path (-C path) added for when you want to sync + only some files' contents, not the whole working tree. -- Joey Hess Thu, 02 Mar 2017 12:51:40 -0400 diff --git a/Command/Sync.hs b/Command/Sync.hs index d4d45e2e4..f2c1945a7 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -63,7 +63,7 @@ cmd :: Command cmd = withGlobalOptions [jobsOption] $ command "sync" SectionCommon "synchronize local repository with remotes" - (paramRepeating paramRemote) (seek <$$> optParser) + (paramRepeating paramRemote) (seek <--< optParser) data SyncOptions = SyncOptions { syncWith :: CmdParams @@ -74,6 +74,7 @@ data SyncOptions = SyncOptions , pushOption :: Bool , contentOption :: Bool , noContentOption :: Bool + , contentOfOption :: [FilePath] , keyOptions :: Maybe KeyOptions } @@ -109,8 +110,29 @@ optParser desc = SyncOptions ( long "no-content" <> help "do not transfer file contents" ) + <*> many (strOption + ( long "content-of" + <> short 'C' + <> help "transfer file contents of files in a given location" + <> metavar paramPath + )) <*> optional parseAllOption +-- Since prepMerge changes the working directory, FilePath options +-- have to be adjusted. +instance DeferredParseClass SyncOptions where + finishParse v = SyncOptions + <$> pure (syncWith v) + <*> pure (commitOption v) + <*> pure (noCommitOption v) + <*> pure (messageOption v) + <*> pure (pullOption v) + <*> pure (pushOption v) + <*> pure (contentOption v) + <*> pure (noContentOption v) + <*> liftIO (mapM absPath (contentOfOption v)) + <*> pure (keyOptions v) + seek :: SyncOptions -> CommandSeek seek o = allowConcurrentOutput $ do prepMerge @@ -148,6 +170,7 @@ seek o = allowConcurrentOutput $ do mapM_ (commandAction . withbranch . pushRemote o) gitremotes where shouldsynccontent = pure (contentOption o) + <||> pure (not (null (contentOfOption o))) <||> (pure (not (noContentOption o)) <&&> getGitConfigVal annexSyncContent) type CurrBranch = (Maybe Git.Branch, Maybe Adjustment) @@ -510,7 +533,7 @@ seekSyncContent o rs = do mvar <- liftIO newEmptyMVar bloom <- case keyOptions o of Just WantAllKeys -> Just <$> genBloomFilter (seekworktree mvar []) - _ -> seekworktree mvar [] (const noop) >> pure Nothing + _ -> seekworktree mvar (contentOfOption o) (const noop) >> pure Nothing withKeyOptions' (keyOptions o) False (return (seekkeys mvar bloom)) (const noop) diff --git a/doc/git-annex-sync.mdwn b/doc/git-annex-sync.mdwn index e29698c4b..97c63d340 100644 --- a/doc/git-annex-sync.mdwn +++ b/doc/git-annex-sync.mdwn @@ -73,6 +73,14 @@ by running "git annex sync" on the remote. This behavior can be overridden by configuring the preferred content of a repository. See [[git-annex-preferred-content]](1). +* `--content-of=path` `-C path` + + While --content operates on all annexed files in the work tree, + --content-of allows limiting the transferred files to ones in a given + location. + + This option can be repeated multiple times with different paths. + * `--all` This option, when combined with `--content`, makes all available versions diff --git a/doc/todo/sync_content_of_a_single_directory_or_file.mdwn b/doc/todo/sync_content_of_a_single_directory_or_file.mdwn index bbb036ff6..90eb3b432 100644 --- a/doc/todo/sync_content_of_a_single_directory_or_file.mdwn +++ b/doc/todo/sync_content_of_a_single_directory_or_file.mdwn @@ -9,3 +9,6 @@ currently takes. Perhaps `git annex sync --dir==thedir`, which automatically enables content syncing? --[[Joey]] + +> Going with --content-of, so it's clear it enables content syncing. +> With a -C short option. [[done]] --[[Joey]] -- cgit v1.2.3