Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a603f37

Browse files
ux: disable Fast-Forward if current branch is already up to date to its upstream
Signed-off-by: leo <longshuang@msn.cn>
1 parent 619fc3c commit a603f37

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

‎src/Views/BranchTree.axaml.cs‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ private ContextMenu CreateContextMenuForLocalBranch(ViewModels.Repository repo,
586586
{
587587
var current = repo.CurrentBranch;
588588
var menu = new ContextMenu();
589+
var upstream = repo.Branches.Find(x => x.FullName.Equals(branch.Upstream, StringComparison.Ordinal));
589590

590591
var push = new MenuItem();
591592
push.Header = App.Text("BranchCM.Push", branch.Name);
@@ -602,27 +603,21 @@ private ContextMenu CreateContextMenuForLocalBranch(ViewModels.Repository repo,
602603
{
603604
if (!repo.IsBare)
604605
{
605-
if (!string.IsNullOrEmpty(branch.Upstream))
606+
if (upstream!=null)
606607
{
607-
var upstream = branch.Upstream.Substring(13);
608608
var fastForward = new MenuItem();
609-
fastForward.Header = App.Text("BranchCM.FastForward", upstream);
609+
fastForward.Header = App.Text("BranchCM.FastForward", upstream.FriendlyName);
610610
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
611-
fastForward.IsEnabled = branch.TrackStatus.Ahead.Count == 0;
611+
fastForward.IsEnabled = branch.TrackStatus.Ahead.Count == 0&&branch.TrackStatus.Behind.Count>0;
612612
fastForward.Click += (_, e) =>
613613
{
614-
var b = repo.Branches.Find(x => x.FriendlyName == upstream);
615-
if (b == null)
616-
return;
617-
618614
if (repo.CanCreatePopup())
619-
repo.ShowAndStartPopup(new ViewModels.Merge(repo, b, branch.Name, true));
620-
615+
repo.ShowAndStartPopup(new ViewModels.Merge(repo, upstream, branch.Name, true));
621616
e.Handled = true;
622617
};
623618

624619
var pull = new MenuItem();
625-
pull.Header = App.Text("BranchCM.Pull", upstream);
620+
pull.Header = App.Text("BranchCM.Pull", upstream.FriendlyName);
626621
pull.Icon = App.CreateMenuIcon("Icons.Pull");
627622
pull.Click += (_, e) =>
628623
{
@@ -656,13 +651,12 @@ private ContextMenu CreateContextMenuForLocalBranch(ViewModels.Repository repo,
656651
}
657652

658653
var worktree = repo.Worktrees.Find(x => x.Branch == branch.FullName);
659-
var upstream = repo.Branches.Find(x => x.FullName == branch.Upstream);
660654
if (upstream != null && worktree == null)
661655
{
662656
var fastForward = new MenuItem();
663657
fastForward.Header = App.Text("BranchCM.FastForward", upstream.FriendlyName);
664658
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
665-
fastForward.IsEnabled = branch.TrackStatus.Ahead.Count == 0;
659+
fastForward.IsEnabled = branch.TrackStatus.Ahead.Count == 0&&branch.TrackStatus.Behind.Count>0;
666660
fastForward.Click += (_, e) =>
667661
{
668662
if (repo.CanCreatePopup())

‎src/Views/Histories.axaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ private void FillCurrentBranchMenu(ContextMenu menu, ViewModels.Repository repo,
912912
var fastForward = new MenuItem();
913913
fastForward.Header = App.Text("BranchCM.FastForward", upstream);
914914
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
915-
fastForward.IsEnabled = current.TrackStatus.Ahead.Count == 0;
915+
fastForward.IsEnabled = current.TrackStatus.Ahead.Count == 0&&current.TrackStatus.Behind.Count>0;
916916
fastForward.Click += (_, e) =>
917917
{
918918
var b = repo.Branches.Find(x => x.FriendlyName == upstream);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /