aboutsummaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-03-20 16:00:06 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-03-20 16:00:48 -0400
commit11025aaa449495db399cd02cafc15cec5923281c (patch)
tree6af74adabd1e5fa7cab47df300d87f2b5612c023 /Command
parentfbf69ca7b3eee84c2284d260aa70f106ff9d6d57 (diff)
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.
Diffstat (limited to 'Command')
-rw-r--r--Command/Sync.hs27
1 files changed, 25 insertions, 2 deletions
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)