sync: Pass --allow-unrelated-histories to git merge when used with git git 2.9.0...
authorJoey Hess <joeyh@joeyh.name>
Tue, 15 Nov 2016 22:26:17 +0000 (18:26 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 15 Nov 2016 22:26:17 +0000 (18:26 -0400)
This makes merging a remote into a freshly created direct mode repository
work the same as it works in indirect mode.

The git-annex branches would get merged in any case by a sync,
since that doesn't use git merge.

This might need to be revisited later to better mirror git's behavior.

Assistant/Sync.hs
Assistant/Threads/Merger.hs
CHANGELOG
Command/Sync.hs

index 9b9e7ebe5e06a204f4ea1e088b000fc6f6f93a8a..ff34c0656bbbde0cfcdde8804b6dfe93afde5776 100644 (file)
@@ -21,7 +21,6 @@ import Utility.Parallel
 import qualified Git
 import qualified Git.Command
 import qualified Git.Ref
-import qualified Git.Merge
 import qualified Remote
 import qualified Types.Remote as Remote
 import qualified Remote.List as Remote
@@ -239,19 +238,12 @@ manualPull currentbranch remotes = do
                        )
        haddiverged <- liftAnnex Annex.Branch.forceUpdate
        forM_ normalremotes $ \r ->
-               liftAnnex $ Command.Sync.mergeRemote r currentbranch mergeConfig
+               liftAnnex $ Command.Sync.mergeRemote r currentbranch Command.Sync.mergeConfig
        u <- liftAnnex getUUID
        forM_ xmppremotes $ \r ->
                sendNetMessage $ Pushing (getXMPPClientID r) (PushRequest u)
        return (catMaybes failed, haddiverged)
 
-mergeConfig :: [Git.Merge.MergeConfig]
-mergeConfig = 
-       [ Git.Merge.MergeNonInteractive
-       -- Pairing involves merging unrelated histories
-       , Git.Merge.MergeUnrelatedHistories
-       ]
-
 {- Start syncing a remote, using a background thread. -}
 syncRemote :: Remote -> Assistant ()
 syncRemote remote = do
index 521e5bda6b30666332196deac8de4d39b46c801a..ce0dfbcb42047bd2295f68ed45a4b5fa3e40e512 100644 (file)
@@ -12,7 +12,6 @@ import Assistant.TransferQueue
 import Assistant.BranchChange
 import Assistant.DaemonStatus
 import Assistant.ScanRemotes
-import Assistant.Sync
 import Utility.DirWatcher
 import Utility.DirWatcher.Types
 import qualified Annex.Branch
@@ -86,7 +85,7 @@ onChange file
                                        , "into", Git.fromRef b
                                        ]
                                void $ liftAnnex $ Command.Sync.merge
-                                       currbranch mergeConfig
+                                       currbranch Command.Sync.mergeConfig
                                        Git.Branch.AutomaticCommit
                                        changedbranch
        mergecurrent _ = noop
index 33f434df461493ddb98fae27e308e46cb9288f78..a792d71cc7b4c4be06dcbb35e97db146e1100891 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,9 @@ git-annex (6.20161112) UNRELEASED; urgency=medium
     if so, either use stack to build, or run cabal with 
     --constraint='persistent ==2.2.4.1'
     Hopefully this mess with esqueleto will be resolved soon.
+  * sync: Pass --allow-unrelated-histories to git merge when used with git
+    git 2.9.0 or newer. This makes merging a remote into a freshly created
+    direct mode repository work the same as it works in indirect mode.
 
  -- Joey Hess <id@joeyh.name>  Tue, 15 Nov 2016 11:15:27 -0400
 
index d7edac7435c3965fe65da4a0ded52bf29ddb0b51..fb80c3e74b90e3fe52b6b0ed2bc37bf139c2277d 100644 (file)
@@ -169,7 +169,12 @@ prepMerge :: Annex ()
 prepMerge = Annex.changeDirectory =<< fromRepo Git.repoPath
 
 mergeConfig :: [Git.Merge.MergeConfig] 
-mergeConfig = [Git.Merge.MergeNonInteractive]
+mergeConfig = 
+       [ Git.Merge.MergeNonInteractive
+       -- In several situations, unrelated histories should be merged
+       -- together. This includes pairing in the assistant etc.
+       , Git.Merge.MergeUnrelatedHistories
+       ]
 
 merge :: CurrBranch -> [Git.Merge.MergeConfig] -> Git.Branch.CommitMode -> Git.Branch -> Annex Bool
 merge (Just b, Just adj) mergeconfig commitmode tomerge =