summaryrefslogtreecommitdiff
path: root/Command/Sync.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-06-16 16:50:03 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-06-16 16:50:03 -0400
commit712deee42b122f0ec07866e6bd7770343cee971c (patch)
tree4eb2525edc3cf17d2f6710c7ce52eb28d423f28b /Command/Sync.hs
parentc9d9fca2ed950b32be992d5ac2a055c8246f52a5 (diff)
sync: Add support for --all and --unused.
Diffstat (limited to 'Command/Sync.hs')
-rw-r--r--Command/Sync.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index dbf16992d..88449384d 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -58,6 +58,8 @@ syncOptions :: [Option]
syncOptions =
[ contentOption
, messageOption
+ , allOption
+ , unusedOption
]
contentOption :: Option
@@ -371,12 +373,19 @@ newer remote b = do
seekSyncContent :: [Remote] -> Annex Bool
seekSyncContent rs = do
mvar <- liftIO newEmptyMVar
- mapM_ (go mvar) =<< seekHelper LsFiles.inRepo []
+ -- Always start with the work tree; this ensures that preferred
+ -- content expressions that match files match, even when in --all
+ -- mode.
+ seekworktree mvar []
+ withKeyOptions' False (seekkeys mvar) (const noop) []
liftIO $ not <$> isEmptyMVar mvar
where
- go mvar f = ifAnnexed f
- (\v -> void (liftIO (tryPutMVar mvar ())) >> syncFile rs (Just f) v)
- noop
+ seekworktree mvar = seekHelper LsFiles.inRepo >=>
+ mapM_ (\f -> ifAnnexed f (go mvar (Just f)) noop)
+ seekkeys mvar getkeys = mapM_ (go mvar Nothing) =<< getkeys
+ go mvar af k = do
+ void $ liftIO $ tryPutMVar mvar ()
+ syncFile rs af k
syncFile :: [Remote] -> AssociatedFile -> Key -> Annex ()
syncFile rs af k = do