From 38319385c2953bb8ae07393794599e9564ea4eba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Dr=C3=B6=C3=9Fler?=
 <m.droessler@handelsblattgroup.com>
Date: Tue, 12 Feb 2019 14:24:36 +0100
Subject: [PATCH 1/5] support additionalMergeOptions e.g. to specify -Xtheirs

---
 .../maven/plugin/gitflow/AbstractGitFlowMojo.java     | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
index c433d08f..5ce65a43 100644
--- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
+++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
@@ -154,6 +154,9 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
     @Parameter(defaultValue = "${settings}", readonly = true)
     protected Settings settings;
 
+    @Parameter(property = "additionalMergeOptions")
+    protected String additionalMergeOptions;
+
     /**
      * Initializes command line executables.
      * 
@@ -638,16 +641,16 @@ protected void gitMerge(final String branchName, boolean rebase, boolean noff, b
         }
         if (rebase) {
             getLog().info("Rebasing '" + branchName + "' branch.");
-            executeGitCommand("rebase", sign, branchName);
+            executeGitCommand("rebase", additionalMergeOptions, sign, branchName);
         } else if (ffonly) {
             getLog().info("Merging (--ff-only) '" + branchName + "' branch.");
-            executeGitCommand("merge", "--ff-only", sign, branchName);
+            executeGitCommand("merge", additionalMergeOptions, "--ff-only", sign, branchName);
         } else if (noff) {
             getLog().info("Merging (--no-ff) '" + branchName + "' branch.");
-            executeGitCommand("merge", "--no-ff", sign, branchName, msgParam, msg);
+            executeGitCommand("merge", additionalMergeOptions, "--no-ff", sign, branchName, msgParam, msg);
         } else {
             getLog().info("Merging '" + branchName + "' branch.");
-            executeGitCommand("merge", sign, branchName, msgParam, msg);
+            executeGitCommand("merge", additionalMergeOptions, sign, branchName, msgParam, msg);
         }
     }
 

From 70954683e625c92e11d8500335f30a8829e27d6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Dr=C3=B6=C3=9Fler?=
 <m.droessler@handelsblattgroup.com>
Date: Thu, 14 Feb 2019 09:54:10 +0100
Subject: [PATCH 2/5] updated documentation

---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index 6b9d0b7a..da12717c 100644
--- a/README.md
+++ b/README.md
@@ -246,6 +246,8 @@ Release branch can be merged with `--ff-only` option by setting `releaseMergeFFO
 
 Feature branch can be squashed before merging by setting `featureSquash` parameter to `true`. The default value is `false` (i.e. merge w/o squash will be performed).
 
+You can also specify the optional parameter `additionalMergeOptions` for goals with merge-operations. It takes an arbitrary string, that will be appended to the merge-command. This is useful when in need for advanced options like `-Xtheirs`.
+
 ### Running custom Maven goals
 
 The `preReleaseGoals` parameter can be used in `gitflow:release-finish` and `gitflow:release` goals to run defined Maven goals before the release.

From 27638fb53660086ef44a2876fc9a6bcb1a63ee9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Dr=C3=B6=C3=9Fler?=
 <m.droessler@handelsblattgroup.com>
Date: Thu, 14 Feb 2019 19:17:10 +0100
Subject: [PATCH 3/5] support different merge-options on release-finish for
 merging into production-branch and dev-branch

---
 .../plugin/gitflow/AbstractGitFlowMojo.java   | 27 ++++++++++++++++++-
 .../gitflow/GitFlowReleaseFinishMojo.java     | 10 +++++--
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
index 5ce65a43..99dfd93d 100644
--- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
+++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
@@ -613,7 +613,7 @@ protected void gitCommit(String message, Map<String, String> map)
 
     /**
      * Executes git rebase or git merge --ff-only or git merge --no-ff or git merge.
-     * 
+     *
      * @param branchName
      *            Branch name to merge.
      * @param rebase
@@ -629,6 +629,31 @@ protected void gitCommit(String message, Map<String, String> map)
      */
     protected void gitMerge(final String branchName, boolean rebase, boolean noff, boolean ffonly, String message)
             throws MojoFailureException, CommandLineException {
+        gitMerge(branchName, rebase, noff, ffonly, message, additionalMergeOptions);
+    }
+
+    /**
+     * Executes git rebase or git merge --ff-only or git merge --no-ff or git merge.
+     * 
+     * @param branchName
+     *            Branch name to merge.
+     * @param rebase
+     *            Do rebase.
+     * @param noff
+     *            Merge with --no-ff.
+     * @param ffonly
+     *            Merge with --ff-only.
+     * @param message
+     *            Merge commit message.
+     * @param additionalMergeOptions
+     *            additional commandline options for the merge e.g. "-Xtheirs"
+     *
+     * @throws MojoFailureException
+     * @throws CommandLineException
+     */
+    protected void gitMerge(final String branchName, boolean rebase, boolean noff, boolean ffonly,
+                            final String message, final String additionalMergeOptions)
+            throws MojoFailureException, CommandLineException {
         String sign = "";
         if (gpgSignCommit) {
             sign = "-S";
diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java
index ee57abb7..a9f3de03 100644
--- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java
+++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java
@@ -159,6 +159,12 @@ public class GitFlowReleaseFinishMojo extends AbstractGitFlowMojo {
     @Parameter(property = "useSnapshotInRelease", defaultValue = "false")
     private boolean useSnapshotInRelease;
 
+    @Parameter(property = "productionBranchMergeOptions")
+    private String productionBranchMergeOptions;
+
+    @Parameter(property = "devBranchMergeOptions")
+    private String devBranchMergeOptions;
+
     /** {@inheritDoc} */
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
@@ -238,7 +244,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
             gitCheckout(gitFlowConfig.getProductionBranch());
 
             gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF, releaseMergeFFOnly,
-                    commitMessages.getReleaseFinishMergeMessage());
+                    commitMessages.getReleaseFinishMergeMessage(), productionBranchMergeOptions);
 
             // get current project version from pom
             final String currentVersion = getCurrentProjectVersion();
@@ -278,7 +284,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
                 }
 
                 // merge branch master into develop
-                gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF, false, null);
+                gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF, false, null, devBranchMergeOptions);
 
                 if (commitDevelopmentVersionAtStart && useSnapshotInRelease) {
                     // updating develop poms version back to pre merge state

From 757357353f4c5091ec9a39bd0f791b7a451f8125 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Dr=C3=B6=C3=9Fler?=
 <m.droessler@handelsblattgroup.com>
Date: Mon, 25 Mar 2019 17:15:26 +0100
Subject: [PATCH 4/5] support different merge-options on hotfix-finish for
 merging into production-branch and dev-branch

---
 .../plugin/gitflow/AbstractGitFlowMojo.java   | 19 ++++++++++++++++++-
 .../gitflow/GitFlowHotfixFinishMojo.java      | 12 +++++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
index c2aa65ab..21109011 100644
--- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
+++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java
@@ -704,7 +704,24 @@ protected void gitMerge(final String branchName, boolean rebase, boolean noff, b
      */
     protected void gitMergeNoff(final String branchName)
             throws MojoFailureException, CommandLineException {
-        gitMerge(branchName, false, true, false, null, null);
+        gitMergeNoff(branchName, additionalMergeOptions);
+    }
+
+    /**
+     * Executes git merge --no-ff.
+     *
+     * @param branchName
+     *            Branch name to merge.
+     *
+     * @param additionalMergeOptions
+     *            additional commandline options for the merge e.g. "-Xtheirs"
+     *
+     * @throws MojoFailureException
+     * @throws CommandLineException
+     */
+    protected void gitMergeNoff(final String branchName, final String additionalMergeOptions)
+            throws MojoFailureException, CommandLineException {
+        gitMerge(branchName, false, true, false, null, null, additionalMergeOptions);
     }
 
     /**
diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java
index a9896a4f..07c1f43f 100644
--- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java
+++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixFinishMojo.java
@@ -109,6 +109,12 @@ public class GitFlowHotfixFinishMojo extends AbstractGitFlowMojo {
     @Parameter(property = "skipMergeDevBranch", defaultValue = "false")
     private boolean skipMergeDevBranch = false;
 
+    @Parameter(property = "productionBranchMergeOptions")
+    private String productionBranchMergeOptions;
+
+    @Parameter(property = "devBranchMergeOptions")
+    private String devBranchMergeOptions;
+
     /** {@inheritDoc} */
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
@@ -199,7 +205,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
             }
 
             // git merge --no-ff hotfix/...
-            gitMergeNoff(hotfixBranchName);
+            gitMergeNoff(hotfixBranchName, productionBranchMergeOptions);
 
             final String currentVersion = getCurrentProjectVersion();
 
@@ -243,7 +249,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
                     }
 
                     // git merge --no-ff hotfix/...
-                    gitMergeNoff(hotfixBranchName);
+                    gitMergeNoff(hotfixBranchName, devBranchMergeOptions);
 
                     if (!currentVersion.equals(releaseBranchVersion)) {
                         mvnSetVersions(releaseBranchVersion);
@@ -263,7 +269,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
                         gitCommit(commitMessages.getHotfixVersionUpdateMessage());
 
                         // git merge --no-ff hotfix/...
-                        gitMergeNoff(hotfixBranchName);
+                        gitMergeNoff(hotfixBranchName, devBranchMergeOptions);
 
                         // which version to increment
                         GitFlowVersionInfo hotfixVersionInfo = new GitFlowVersionInfo(

From b85c8a4ee2d713df89dee4d992e45b0e0197e9b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Dr=C3=B6=C3=9Fler?=
 <m.droessler@handelsblattgroup.com>
Date: Mon, 25 Mar 2019 17:21:57 +0100
Subject: [PATCH 5/5] updated documentation

---
 README.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/README.md b/README.md
index ab64bc46..6c096e85 100644
--- a/README.md
+++ b/README.md
@@ -251,6 +251,9 @@ Feature branch can be squashed before merging by setting `featureSquash` paramet
 
 You can also specify the optional parameter `additionalMergeOptions` for goals with merge-operations. It takes an arbitrary string, that will be appended to the merge-command. This is useful when in need for advanced options like `-Xtheirs`.
 
+For the `gitflow:hotfix-finish` and `gitflow:release-finish` goals it is also possible to specify different merge-options for merging into master and development-branch:
+`productionBranchMergeOptions` and `devBranchMergeOptions`.
+
 ### Running custom Maven goals
 
 The `preReleaseGoals` parameter can be used in `gitflow:release-finish` and `gitflow:release` goals to run defined Maven goals before the release.