summaryrefslogtreecommitdiff
path: root/Command/Sync.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Command/Sync.hs')
-rw-r--r--Command/Sync.hs27
1 files changed, 24 insertions, 3 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index f7410112e..95ce0697e 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -15,6 +15,7 @@ import qualified Annex
import qualified Annex.Branch
import qualified Annex.Queue
import Annex.Content
+import Annex.Content.Direct
import Annex.CatFile
import qualified Git.Command
import qualified Git.LsFiles as LsFiles
@@ -129,19 +130,39 @@ pullRemote remote branch = do
{- The remote probably has both a master and a synced/master branch.
- Which to merge from? Well, the master has whatever latest changes
- were committed, while the synced/master may have changes that some
- - other remote synced to this remote. So, merge them both. -}
+ - other remote synced to this remote. So, merge them both.
+ -
+ - In direct mode, updates associated files mappings for the files that
+ - were changed by the merge.
+ -}
mergeRemote :: Remote -> (Maybe Git.Ref) -> CommandCleanup
mergeRemote remote b = case b of
Nothing -> do
branch <- inRepo Git.Branch.currentUnsafe
- all id <$> (mapM merge $ branchlist branch)
- Just _ -> all id <$> (mapM merge =<< tomerge (branchlist b))
+ update branch $
+ all id <$> (mapM merge $ branchlist branch)
+ Just branch -> update (Just branch) $
+ all id <$> (mapM merge =<< tomerge (branchlist b))
where
merge = mergeFrom . remoteBranch remote
tomerge branches = filterM (changed remote) branches
branchlist Nothing = []
branchlist (Just branch) = [branch, syncBranch branch]
+ update Nothing a = a
+ update (Just branch) a = ifM isDirect
+ ( do
+ old <- inRepo $ Git.Ref.sha branch
+ r <- a
+ new <- inRepo $ Git.Ref.sha branch
+ case (old, new) of
+ (Just oldsha, Just newsha) -> do
+ updateAssociatedFiles oldsha newsha
+ _ -> noop
+ return r
+ , a
+ )
+
pushRemote :: Remote -> Git.Ref -> CommandStart
pushRemote remote branch = go =<< needpush
where