Skip to content

Commit

Permalink
Add support for "--rebase-merges" for newest version of git
Browse files Browse the repository at this point in the history
  • Loading branch information
pmiossec committed Jul 14, 2019
1 parent 2d9025e commit 519c0dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GitCommands/Git/GitCommandHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
3 changes: 3 additions & 0 deletions GitCommands/Git/GitVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class GitVersion : IComparable<GitVersion>
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");
Expand Down Expand Up @@ -124,6 +125,8 @@ int Get(IReadOnlyList<int> 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
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/GitCommandsTests/Git/GitCommandHelpersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand All @@ -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'?
Expand Down

0 comments on commit 519c0dc

Please sign in to comment.