diff --git a/GitCommands/Git/GitCommandHelpers.cs b/GitCommands/Git/GitCommandHelpers.cs index 4dd478af9b7..8935b81c306 100644 --- a/GitCommands/Git/GitCommandHelpers.cs +++ b/GitCommands/Git/GitCommandHelpers.cs @@ -403,7 +403,7 @@ public static ArgumentString RebaseCmd(string branch, bool interactive, bool pre { interactive, "-i" }, { interactive && autosquash, "--autosquash" }, { interactive && !autosquash, "--no-autosquash" }, - { preserveMerges, "--preserve-merges" }, + { preserveMerges, GitVersion.Current.SupportRebaseMerges ? "--rebase-merges" : "--preserve-merges" }, { autoStash, "--autostash" }, from.QuoteNE(), branch.Quote(), diff --git a/GitCommands/Git/GitVersion.cs b/GitCommands/Git/GitVersion.cs index ec9c766a9a8..cf9e2fb04d0 100644 --- a/GitCommands/Git/GitVersion.cs +++ b/GitCommands/Git/GitVersion.cs @@ -19,6 +19,7 @@ public class GitVersion : IComparable private static readonly GitVersion v2_11_0 = new GitVersion("2.11.0"); private static readonly GitVersion v2_15_0 = new GitVersion("2.15.0"); private static readonly GitVersion v2_15_2 = new GitVersion("2.15.2"); + private static readonly GitVersion v2_19_0 = new GitVersion("2.19.0"); public static readonly GitVersion LastSupportedVersion = v2_11_0; public static readonly GitVersion LastRecommendedVersion = new GitVersion("2.22.0"); @@ -124,6 +125,8 @@ int Get(IReadOnlyList values, int index) public bool SupportNoOptionalLocks => this >= v2_15_2; + public bool SupportRebaseMerges => this >= v2_19_0; + public bool IsUnknown => _a == 0 && _b == 0 && _c == 0 && _d == 0; // Returns true if it's possible to pass given string as command line diff --git a/UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs b/UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs index 4be3fa8790c..eddc264ac9b 100644 --- a/UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs +++ b/UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs @@ -605,7 +605,7 @@ public void RebaseCmd() "-c rebase.autoSquash=false rebase -i --no-autosquash \"branch\"", GitCommandHelpers.RebaseCmd("branch", interactive: true, preserveMerges: false, autosquash: false, autoStash: false).Arguments); Assert.AreEqual( - "-c rebase.autoSquash=false rebase --preserve-merges \"branch\"", + GitVersion.Current.SupportRebaseMerges ? "-c rebase.autoSquash=false rebase --rebase-merges \"branch\"" : "-c rebase.autoSquash=false rebase --preserve-merges \"branch\"", GitCommandHelpers.RebaseCmd("branch", interactive: false, preserveMerges: true, autosquash: false, autoStash: false).Arguments); Assert.AreEqual( "-c rebase.autoSquash=false rebase \"branch\"", @@ -617,7 +617,7 @@ public void RebaseCmd() "-c rebase.autoSquash=false rebase -i --autosquash \"branch\"", GitCommandHelpers.RebaseCmd("branch", interactive: true, preserveMerges: false, autosquash: true, autoStash: false).Arguments); Assert.AreEqual( - "-c rebase.autoSquash=false rebase -i --autosquash --preserve-merges --autostash \"branch\"", + GitVersion.Current.SupportRebaseMerges ? "-c rebase.autoSquash=false rebase -i --autosquash --rebase-merges --autostash \"branch\"" : "-c rebase.autoSquash=false rebase -i --autosquash --preserve-merges --autostash \"branch\"", GitCommandHelpers.RebaseCmd("branch", interactive: true, preserveMerges: true, autosquash: true, autoStash: true).Arguments); // TODO quote 'onto'?