summaryrefslogtreecommitdiff
path: root/Command/Sync.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-04-22 14:26:44 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-04-22 14:26:44 -0400
commitc4b2bd9869c4cc1ae036e5be9d1032fb1ee99804 (patch)
tree86a1e3cc74561e7dd9c16855e53685a8f001b284 /Command/Sync.hs
parentb48a044d26bb607da9962b9086e9da2db9e11620 (diff)
assistant: Deal with upcoming git's refusal to merge unrelated histories by default
git 2.8.1 (or perhaps 2.9.0) is going to prevent git merge from merging in unrelated branches. Since the webapp's pairing etc features often combine together repositories with unrelated histories, work around this behavior change by setting GIT_MERGE_ALLOW_UNRELATED_HISTORIES when the assistant merges. Note though that this is not done for git annex sync's merges, so it will follow git's default or configured behavior.
Diffstat (limited to 'Command/Sync.hs')
-rw-r--r--Command/Sync.hs31
1 files changed, 17 insertions, 14 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index 5ec2f8bb3..3e68ad8cc 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -32,6 +32,7 @@ import Annex.Hook
import qualified Git.Command
import qualified Git.LsFiles as LsFiles
import qualified Git.Branch
+import qualified Git.Merge
import qualified Git.Types as Git
import qualified Git.Ref
import qualified Git
@@ -112,7 +113,7 @@ seek o = allowConcurrentOutput $ do
mapM_ includeCommandAction $ concat
[ [ commit o ]
, [ withbranch mergeLocal ]
- , map (withbranch . pullRemote o) gitremotes
+ , map (withbranch . pullRemote o mergeconfig) gitremotes
, [ mergeAnnex ]
]
when (contentOption o) $
@@ -123,13 +124,15 @@ seek o = allowConcurrentOutput $ do
-- and merge again to avoid our push overwriting
-- those changes.
mapM_ includeCommandAction $ concat
- [ map (withbranch . pullRemote o) gitremotes
+ [ map (withbranch . pullRemote o mergeconfig) gitremotes
, [ commitAnnex, mergeAnnex ]
]
void $ includeCommandAction $ withbranch pushLocal
-- Pushes to remotes can run concurrently.
mapM_ (commandAction . withbranch . pushRemote o) gitremotes
+ where
+ mergeconfig = [Git.Merge.MergeNonInteractive]
type CurrBranch = (Maybe Git.Branch, Maybe Adjustment)
@@ -166,11 +169,11 @@ getCurrBranch = do
prepMerge :: Annex ()
prepMerge = Annex.changeDirectory =<< fromRepo Git.repoPath
-merge :: CurrBranch -> Git.Branch.CommitMode -> Git.Branch -> Annex Bool
-merge (Just b, Just adj) commitmode tomerge =
- updateAdjustedBranch tomerge (b, adj) commitmode
-merge (b, _) commitmode tomerge =
- autoMergeFrom tomerge b commitmode
+merge :: CurrBranch -> [Git.Merge.MergeConfig] -> Git.Branch.CommitMode -> Git.Branch -> Annex Bool
+merge (Just b, Just adj) mergeconfig commitmode tomerge =
+ updateAdjustedBranch tomerge (b, adj) mergeconfig commitmode
+merge (b, _) mergeconfig commitmode tomerge =
+ autoMergeFrom tomerge b mergeconfig commitmode
syncBranch :: Git.Branch -> Git.Branch
syncBranch = Git.Ref.under "refs/heads/synced" . fromDirectBranch . fromAdjustedBranch
@@ -257,7 +260,7 @@ mergeLocal currbranch@(Just branch, madj) = go =<< needmerge
go False = stop
go True = do
showStart "merge" $ Git.Ref.describe syncbranch
- next $ next $ merge currbranch Git.Branch.ManualCommit syncbranch
+ next $ next $ merge currbranch [Git.Merge.MergeNonInteractive] Git.Branch.ManualCommit syncbranch
branch' = maybe branch (adjBranch . originalToAdjusted branch) madj
mergeLocal (Nothing, _) = stop
@@ -291,13 +294,13 @@ updateBranch syncbranch updateto g =
, Param $ Git.fromRef $ updateto
] g
-pullRemote :: SyncOptions -> Remote -> CurrBranch -> CommandStart
-pullRemote o remote branch = stopUnless (pure $ pullOption o) $ do
+pullRemote :: SyncOptions -> [Git.Merge.MergeConfig] -> Remote -> CurrBranch -> CommandStart
+pullRemote o mergeconfig remote branch = stopUnless (pure $ pullOption o) $ do
showStart "pull" (Remote.name remote)
next $ do
showOutput
stopUnless fetch $
- next $ mergeRemote remote branch
+ next $ mergeRemote remote branch mergeconfig
where
fetch = inRepoWithSshOptionsTo (Remote.repo remote) (Remote.gitconfig remote) $
Git.Command.runBool
@@ -308,8 +311,8 @@ pullRemote o remote branch = stopUnless (pure $ pullOption o) $ do
- were committed (or pushed changes, if this is a bare remote),
- while the synced/master may have changes that some
- other remote synced to this remote. So, merge them both. -}
-mergeRemote :: Remote -> CurrBranch -> CommandCleanup
-mergeRemote remote currbranch = ifM isBareRepo
+mergeRemote :: Remote -> CurrBranch -> [Git.Merge.MergeConfig] -> CommandCleanup
+mergeRemote remote currbranch mergeconfig = ifM isBareRepo
( return True
, case currbranch of
(Nothing, _) -> do
@@ -321,7 +324,7 @@ mergeRemote remote currbranch = ifM isBareRepo
)
where
mergelisted getlist = and <$>
- (mapM (merge currbranch Git.Branch.ManualCommit . remoteBranch remote) =<< getlist)
+ (mapM (merge currbranch mergeconfig Git.Branch.ManualCommit . remoteBranch remote) =<< getlist)
tomerge = filterM (changed remote)
branchlist Nothing = []
branchlist (Just branch) = [branch, syncBranch branch]