use --allow-unrelated-histories for now

I'd prefer to use the env var, but let's use what git currently supports.
Revert this when the env var gets supported.

Note that the version checking assumes git 2.8.2 will get support for the
switch.
This commit is contained in:
Joey Hess 2016-04-22 15:56:13 -04:00
parent e4f159adb3
commit 6ec154d70c
Failed to extract signature
2 changed files with 20 additions and 17 deletions

View file

@ -16,9 +16,9 @@ module Git.Merge (
import Common import Common
import Git import Git
import Git.Command import Git.Command
import Git.BuildVersion import qualified Git.BuildVersion
import qualified Git.Version
import Git.Branch (CommitMode(..)) import Git.Branch (CommitMode(..))
import Git.Env
data MergeConfig data MergeConfig
= MergeNonInteractive = MergeNonInteractive
@ -32,20 +32,30 @@ merge = merge' []
merge' :: [CommandParam] -> Ref -> [MergeConfig] -> CommitMode -> Repo -> IO Bool merge' :: [CommandParam] -> Ref -> [MergeConfig] -> CommitMode -> Repo -> IO Bool
merge' extraparams branch mergeconfig commitmode r merge' extraparams branch mergeconfig commitmode r
| MergeNonInteractive `notElem` mergeconfig || older "1.7.7.6" = | MergeNonInteractive `notElem` mergeconfig || Git.BuildVersion.older "1.7.7.6" =
go [Param $ fromRef branch] go [Param $ fromRef branch]
| otherwise = go [Param "--no-edit", Param $ fromRef branch] | otherwise = go [Param "--no-edit", Param $ fromRef branch]
where where
go ps = runBool (sp ++ [Param "merge"] ++ ps ++ extraparams) go ps = merge'' (sp ++ [Param "merge"] ++ ps ++ extraparams) mergeconfig r
=<< cfgRepo mergeconfig r
sp sp
| commitmode == AutomaticCommit = | commitmode == AutomaticCommit =
[Param "-c", Param "commit.gpgsign=false"] [Param "-c", Param "commit.gpgsign=false"]
| otherwise = [] | otherwise = []
merge'' :: [CommandParam] -> [MergeConfig] -> Repo -> IO Bool
merge'' ps mergeconfig r
| MergeUnrelatedHistories `elem` mergeconfig =
ifM (Git.Version.older "2.8.2")
( go (ps ++ [Param "--allow-unrelated-histories"])
, go ps
)
| otherwise = go ps
where
go ps' = runBool ps' r
{- Stage the merge into the index, but do not commit it.-} {- Stage the merge into the index, but do not commit it.-}
stageMerge :: Ref -> [MergeConfig] -> Repo -> IO Bool stageMerge :: Ref -> [MergeConfig] -> Repo -> IO Bool
stageMerge branch mergeconfig r = runBool stageMerge branch = merge''
[ Param "merge" [ Param "merge"
, Param "--quiet" , Param "--quiet"
, Param "--no-commit" , Param "--no-commit"
@ -53,10 +63,4 @@ stageMerge branch mergeconfig r = runBool
-- commit. -- commit.
, Param "--no-ff" , Param "--no-ff"
, Param $ fromRef branch , Param $ fromRef branch
] =<< cfgRepo mergeconfig r ]
cfgRepo :: [MergeConfig] -> Repo -> IO Repo
cfgRepo mergeconfig r
| MergeUnrelatedHistories `elem` mergeconfig =
addGitEnv r "GIT_MERGE_ALLOW_UNRELATED_HISTORIES" "1"
| otherwise = return r

7
debian/changelog vendored
View file

@ -19,10 +19,9 @@ git-annex (6.20160419) UNRELEASED; urgency=medium
* git 2.8.1 (or perhaps 2.9.0) is going to prevent git merge from * 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 merging in unrelated branches. Since the webapp's pairing etc features
often combine together repositories with unrelated histories, work around often combine together repositories with unrelated histories, work around
this behavior change by setting GIT_MERGE_ALLOW_UNRELATED_HISTORIES this behavior change when the assistant merges. Note though that this is
when the assistant merges. Note though that this is not done for not done for git annex sync's merges, so it will follow git's default or
git annex sync's merges, so it will follow git's default or configured configured behavior.
behavior.
-- Joey Hess <id@joeyh.name> Tue, 19 Apr 2016 12:57:15 -0400 -- Joey Hess <id@joeyh.name> Tue, 19 Apr 2016 12:57:15 -0400