mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
feature: support --ff-only
option for git merge
command
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
2b95ea2ab1
commit
a0cddaea80
4 changed files with 14 additions and 11 deletions
|
@ -5,6 +5,7 @@
|
|||
public static readonly MergeMode[] Supported =
|
||||
[
|
||||
new MergeMode("Default", "Fast-forward if possible", ""),
|
||||
new MergeMode("Fast-forward", "Refuse to merge when fast-forward is not possible", "--ff-only"),
|
||||
new MergeMode("No Fast-forward", "Always create a merge commit", "--no-ff"),
|
||||
new MergeMode("Squash", "Squash merge", "--squash"),
|
||||
new MergeMode("Don't commit", "Merge without commit", "--no-ff --no-commit"),
|
||||
|
|
|
@ -871,7 +871,7 @@ namespace SourceGit.ViewModels
|
|||
return;
|
||||
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowAndStartPopup(new Merge(_repo, b, current.Name));
|
||||
_repo.ShowAndStartPopup(new Merge(_repo, b, current.Name, true));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
@ -972,7 +972,7 @@ namespace SourceGit.ViewModels
|
|||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Merge(_repo, branch, current.Name));
|
||||
_repo.ShowPopup(new Merge(_repo, branch, current.Name, false));
|
||||
e.Handled = true;
|
||||
};
|
||||
submenu.Items.Add(merge);
|
||||
|
@ -1060,7 +1060,7 @@ namespace SourceGit.ViewModels
|
|||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (_repo.CanCreatePopup())
|
||||
_repo.ShowPopup(new Merge(_repo, branch, current.Name));
|
||||
_repo.ShowPopup(new Merge(_repo, branch, current.Name, false));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@ namespace SourceGit.ViewModels
|
|||
set;
|
||||
}
|
||||
|
||||
public Merge(Repository repo, Models.Branch source, string into)
|
||||
public Merge(Repository repo, Models.Branch source, string into, bool forceFastForward)
|
||||
{
|
||||
_repo = repo;
|
||||
_sourceName = source.FriendlyName;
|
||||
|
||||
Source = source;
|
||||
Into = into;
|
||||
Mode = AutoSelectMergeMode();
|
||||
Mode = forceFastForward ? Models.MergeMode.Supported[1] : AutoSelectMergeMode();
|
||||
View = new Views.Merge() { DataContext = this };
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,14 @@ namespace SourceGit.ViewModels
|
|||
var config = new Commands.Config(_repo.FullPath).Get($"branch.{Into}.mergeoptions");
|
||||
if (string.IsNullOrEmpty(config))
|
||||
return Models.MergeMode.Supported[0];
|
||||
if (config.Equals("--no-ff", StringComparison.Ordinal))
|
||||
if (config.Equals("--ff-only", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[1];
|
||||
if (config.Equals("--squash", StringComparison.Ordinal))
|
||||
if (config.Equals("--no-ff", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[2];
|
||||
if (config.Equals("--no-commit", StringComparison.Ordinal) || config.Equals("--no-ff --no-commit", StringComparison.Ordinal))
|
||||
if (config.Equals("--squash", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[3];
|
||||
if (config.Equals("--no-commit", StringComparison.Ordinal) || config.Equals("--no-ff --no-commit", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[4];
|
||||
|
||||
return Models.MergeMode.Supported[0];
|
||||
}
|
||||
|
|
|
@ -1516,7 +1516,7 @@ namespace SourceGit.ViewModels
|
|||
return;
|
||||
|
||||
if (CanCreatePopup())
|
||||
ShowAndStartPopup(new Merge(this, b, branch.Name));
|
||||
ShowAndStartPopup(new Merge(this, b, branch.Name, true));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
@ -1595,7 +1595,7 @@ namespace SourceGit.ViewModels
|
|||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Merge(this, branch, _currentBranch.Name));
|
||||
ShowPopup(new Merge(this, branch, _currentBranch.Name, false));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -1876,7 +1876,7 @@ namespace SourceGit.ViewModels
|
|||
merge.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new Merge(this, branch, _currentBranch.Name));
|
||||
ShowPopup(new Merge(this, branch, _currentBranch.Name, false));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue