Skip to content

Commit

Permalink
Select remote branch on [Ctrl+]Alt+Click in ROT
Browse files Browse the repository at this point in the history
Implements most improtant part of gitextensions#9194
  • Loading branch information
mstv committed Jun 20, 2021
1 parent 14a9294 commit ee8efe7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions GitUI/BranchTreePanel/RepoObjectsTree.Nodes.Branches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using GitCommands;
using GitCommands.Git;
using GitExtUtils.GitUI.Theming;
using GitUI.BranchTreePanel.Interfaces;
Expand Down Expand Up @@ -43,6 +44,8 @@ protected BaseBranchNode(Tree tree, string fullPath, bool visible)

protected string? AheadBehind { get; set; }

protected string? RelatedBranch { get; set; }

/// <summary>
/// Short name of the branch/branch path. <example>"issue1344"</example>.
/// </summary>
Expand Down Expand Up @@ -78,9 +81,10 @@ public override bool Equals(object obj)
&& Visible == other.Visible;
}

public void UpdateAheadBehind(string aheadBehindData)
public void UpdateAheadBehind(string aheadBehindData, string relatedBranch)
{
AheadBehind = aheadBehindData;
RelatedBranch = relatedBranch;
}

public bool Rebase()
Expand Down Expand Up @@ -128,7 +132,9 @@ protected void SelectRevision()
{
TreeViewNode.TreeView?.BeginInvoke(new Action(() =>
{
UICommands.BrowseGoToRef(FullPath, showNoRevisionMsg: true, toggleSelection: ModifierKeys.HasFlag(Keys.Control));
string branch = RelatedBranch is null || !ModifierKeys.HasFlag(Keys.Alt)
? FullPath : RelatedBranch.Substring(GitRefName.RefsRemotesPrefix.Length);
UICommands.BrowseGoToRef(branch, showNoRevisionMsg: true, toggleSelection: ModifierKeys.HasFlag(Keys.Control));
TreeViewNode.TreeView?.Focus();
}));
}
Expand Down Expand Up @@ -395,9 +401,12 @@ private Nodes FillBranchTree(IReadOnlyList<IGitRef> branches, CancellationToken
bool isVisible = !IsFiltering.Value || _refsSource.Contains(branch.ObjectId);
LocalBranchNode localBranchNode = new(this, branch.ObjectId, branch.Name, branch.Name == currentBranch, isVisible);

if (aheadBehindData is not null && aheadBehindData.ContainsKey(localBranchNode.FullPath))
if (aheadBehindData is not null)
{
localBranchNode.UpdateAheadBehind(aheadBehindData[localBranchNode.FullPath].ToDisplay());
if (aheadBehindData.TryGetValue(localBranchNode.FullPath, out AheadBehindData aheadBehind))
{
localBranchNode.UpdateAheadBehind(aheadBehind.ToDisplay(), aheadBehind.RemoteRef);
}
}

var parent = localBranchNode.CreateRootNode(pathToNode, (tree, parentPath) => new BranchPathNode(tree, parentPath));
Expand Down

0 comments on commit ee8efe7

Please sign in to comment.