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.
This commit is contained in:
parent
c8a6be7eef
commit
64f924dc93
4 changed files with 38 additions and 2 deletions
|
@ -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
|
* 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
|
as they are by git. However, unlike git, git-annex sometimes needs to
|
||||||
pass the -n parameter when using these.
|
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 <id@joeyh.name> Thu, 02 Mar 2017 12:51:40 -0400
|
-- Joey Hess <id@joeyh.name> Thu, 02 Mar 2017 12:51:40 -0400
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ cmd :: Command
|
||||||
cmd = withGlobalOptions [jobsOption] $
|
cmd = withGlobalOptions [jobsOption] $
|
||||||
command "sync" SectionCommon
|
command "sync" SectionCommon
|
||||||
"synchronize local repository with remotes"
|
"synchronize local repository with remotes"
|
||||||
(paramRepeating paramRemote) (seek <$$> optParser)
|
(paramRepeating paramRemote) (seek <--< optParser)
|
||||||
|
|
||||||
data SyncOptions = SyncOptions
|
data SyncOptions = SyncOptions
|
||||||
{ syncWith :: CmdParams
|
{ syncWith :: CmdParams
|
||||||
|
@ -74,6 +74,7 @@ data SyncOptions = SyncOptions
|
||||||
, pushOption :: Bool
|
, pushOption :: Bool
|
||||||
, contentOption :: Bool
|
, contentOption :: Bool
|
||||||
, noContentOption :: Bool
|
, noContentOption :: Bool
|
||||||
|
, contentOfOption :: [FilePath]
|
||||||
, keyOptions :: Maybe KeyOptions
|
, keyOptions :: Maybe KeyOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +110,29 @@ optParser desc = SyncOptions
|
||||||
( long "no-content"
|
( long "no-content"
|
||||||
<> help "do not transfer file contents"
|
<> 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
|
<*> 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 :: SyncOptions -> CommandSeek
|
||||||
seek o = allowConcurrentOutput $ do
|
seek o = allowConcurrentOutput $ do
|
||||||
prepMerge
|
prepMerge
|
||||||
|
@ -148,6 +170,7 @@ seek o = allowConcurrentOutput $ do
|
||||||
mapM_ (commandAction . withbranch . pushRemote o) gitremotes
|
mapM_ (commandAction . withbranch . pushRemote o) gitremotes
|
||||||
where
|
where
|
||||||
shouldsynccontent = pure (contentOption o)
|
shouldsynccontent = pure (contentOption o)
|
||||||
|
<||> pure (not (null (contentOfOption o)))
|
||||||
<||> (pure (not (noContentOption o)) <&&> getGitConfigVal annexSyncContent)
|
<||> (pure (not (noContentOption o)) <&&> getGitConfigVal annexSyncContent)
|
||||||
|
|
||||||
type CurrBranch = (Maybe Git.Branch, Maybe Adjustment)
|
type CurrBranch = (Maybe Git.Branch, Maybe Adjustment)
|
||||||
|
@ -510,7 +533,7 @@ seekSyncContent o rs = do
|
||||||
mvar <- liftIO newEmptyMVar
|
mvar <- liftIO newEmptyMVar
|
||||||
bloom <- case keyOptions o of
|
bloom <- case keyOptions o of
|
||||||
Just WantAllKeys -> Just <$> genBloomFilter (seekworktree mvar [])
|
Just WantAllKeys -> Just <$> genBloomFilter (seekworktree mvar [])
|
||||||
_ -> seekworktree mvar [] (const noop) >> pure Nothing
|
_ -> seekworktree mvar (contentOfOption o) (const noop) >> pure Nothing
|
||||||
withKeyOptions' (keyOptions o) False
|
withKeyOptions' (keyOptions o) False
|
||||||
(return (seekkeys mvar bloom))
|
(return (seekkeys mvar bloom))
|
||||||
(const noop)
|
(const noop)
|
||||||
|
|
|
@ -73,6 +73,14 @@ by running "git annex sync" on the remote.
|
||||||
This behavior can be overridden by configuring the preferred content
|
This behavior can be overridden by configuring the preferred content
|
||||||
of a repository. See [[git-annex-preferred-content]](1).
|
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`
|
* `--all`
|
||||||
|
|
||||||
This option, when combined with `--content`, makes all available versions
|
This option, when combined with `--content`, makes all available versions
|
||||||
|
|
|
@ -9,3 +9,6 @@ currently takes. Perhaps `git annex sync --dir==thedir`, which
|
||||||
automatically enables content syncing?
|
automatically enables content syncing?
|
||||||
|
|
||||||
--[[Joey]]
|
--[[Joey]]
|
||||||
|
|
||||||
|
> Going with --content-of, so it's clear it enables content syncing.
|
||||||
|
> With a -C short option. [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue