* sync: When --quiet is used, run git commit, push, and pull without
their ususual output.
* merge: When --quiet is used, run git merge without its usual output.
+ * sync, merge, post-receive: Avoid merging unrelated histories,
+ which used to be allowed only to support direct mode repositories.
+ (However, sync does still merge unrelated histories when importing
+ trees from special remotes, and the assistant still merges unrelated
+ histories.)
-- Joey Hess <id@joeyh.name> Wed, 14 Jul 2021 14:26:36 -0400
mergeSyncedBranch :: CommandStart
mergeSyncedBranch = do
- mc <- mergeConfig
+ mc <- mergeConfig False
mergeLocal mc def =<< getCurrentBranch
mergeBranch :: Git.Ref -> CommandStart
mergeBranch r = starting "merge" ai si $ do
currbranch <- getCurrentBranch
let o = def { notOnlyAnnexOption = True }
- mc <- mergeConfig
+ mc <- mergeConfig False
next $ merge currbranch mc o Git.Branch.ManualCommit r
where
ai = ActionItemOther (Just (Git.fromRef r))
commandAction (withbranch cleanupLocal)
mapM_ (commandAction . withbranch . cleanupRemote) gitremotes
else do
- mc <- mergeConfig
+ mc <- mergeConfig False
-- Syncing involves many actions, any of which
-- can independently fail, without preventing
content <- shouldSyncContent o
forM_ (filter isImport contentremotes) $
- withbranch . importRemote content o mc
+ withbranch . importRemote content o
forM_ (filter isThirdPartyPopulated contentremotes) $
pullThirdPartyPopulated o
prepMerge :: Annex ()
prepMerge = Annex.changeDirectory . fromRawFilePath =<< fromRepo Git.repoPath
-mergeConfig :: Annex [Git.Merge.MergeConfig]
-mergeConfig = do
+mergeConfig :: Bool -> Annex [Git.Merge.MergeConfig]
+mergeConfig mergeunrelated = do
quiet <- commandProgressDisabled
return $ catMaybes
[ Just Git.Merge.MergeNonInteractive
- -- In several situations, unrelated histories should be
- -- merged together. This includes pairing in the assistant,
- -- merging from a remote into a newly created direct mode
- -- repo, and an initial merge from an import from a special
- -- remote. (Once direct mode is removed, this could be
- -- changed, so only the assistant and import from special
- -- remotes use it.)
- , Just Git.Merge.MergeUnrelatedHistories
- , if quiet then Just Git.Merge.MergeQuiet else Nothing
+ , if mergeunrelated
+ then Just Git.Merge.MergeUnrelatedHistories
+ else Nothing
+ , if quiet
+ then Just Git.Merge.MergeQuiet
+ else Nothing
]
merge :: CurrBranch -> [Git.Merge.MergeConfig] -> SyncOptions -> Git.Branch.CommitMode -> Git.Branch -> Annex Bool
ai = ActionItemOther (Just (Remote.name remote))
si = SeekInput []
-importRemote :: Bool -> SyncOptions -> [Git.Merge.MergeConfig] -> Remote -> CurrBranch -> CommandSeek
-importRemote importcontent o mergeconfig remote currbranch
+importRemote :: Bool -> SyncOptions -> Remote -> CurrBranch -> CommandSeek
+importRemote importcontent o remote currbranch
| not (pullOption o) || not wantpull = noop
| otherwise = case remoteAnnexTrackingBranch (Remote.gitconfig remote) of
Nothing -> noop
if canImportKeys remote importcontent
then do
Command.Import.seekRemote remote branch subdir importcontent (CheckGitIgnore True)
- void $ mergeRemote remote currbranch mergeconfig o
+ -- Importing generates a branch
+ -- that is not initially connected
+ -- to the current branch, so allow
+ -- merging unrelated histories when
+ -- mergeing it.
+ mc <- mergeConfig True
+ void $ mergeRemote remote currbranch mc o
else warning $ "Cannot import from " ++ Remote.name remote ++ " when not syncing content."
where
wantpull = remoteAnnexPull (Remote.gitconfig remote)