diff --git a/GitUI/BranchTreePanel/BaseBranchNode.cs b/GitUI/BranchTreePanel/BaseBranchNode.cs index d96d19a6ab9..3335da67816 100644 --- a/GitUI/BranchTreePanel/BaseBranchNode.cs +++ b/GitUI/BranchTreePanel/BaseBranchNode.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using GitCommands; using GitExtUtils.GitUI.Theming; using GitUI.Properties; @@ -31,6 +32,8 @@ protected BaseBranchNode(Tree tree, string fullPath, bool visible) protected string? AheadBehind { get; set; } + protected string? RelatedBranch { get; set; } + /// /// Short name of the branch/branch path. "issue1344". /// @@ -64,9 +67,10 @@ public override bool Equals(object obj) && (ReferenceEquals(other, this) || string.Equals(FullPath, other.FullPath)); } - public void UpdateAheadBehind(string aheadBehindData) + public void UpdateAheadBehind(string aheadBehindData, string relatedBranch) { AheadBehind = aheadBehindData; + RelatedBranch = relatedBranch; } public bool Rebase() @@ -114,7 +118,9 @@ protected void SelectRevision() { TreeViewNode.TreeView?.BeginInvoke(new Action(() => { - UICommands.BrowseGoToRef(FullPath, showNoRevisionMsg: true, toggleSelection: RepoObjectsTree.ModifierKeys.HasFlag(Keys.Control)); + string branch = RelatedBranch is null || !RepoObjectsTree.ModifierKeys.HasFlag(Keys.Alt) + ? FullPath : RelatedBranch.Substring(startIndex: GitRefName.RefsRemotesPrefix.Length); + UICommands.BrowseGoToRef(branch, showNoRevisionMsg: true, toggleSelection: RepoObjectsTree.ModifierKeys.HasFlag(Keys.Control)); TreeViewNode.TreeView?.Focus(); })); } diff --git a/GitUI/BranchTreePanel/BranchTree.cs b/GitUI/BranchTreePanel/BranchTree.cs index 33a2901c9f6..876ef31feca 100644 --- a/GitUI/BranchTreePanel/BranchTree.cs +++ b/GitUI/BranchTreePanel/BranchTree.cs @@ -100,9 +100,9 @@ private Nodes FillBranchTree(IReadOnlyList 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 && aheadBehindData.TryGetValue(localBranchNode.FullPath, out AheadBehindData aheadBehind)) { - localBranchNode.UpdateAheadBehind(aheadBehindData[localBranchNode.FullPath].ToDisplay()); + localBranchNode.UpdateAheadBehind(aheadBehind.ToDisplay(), aheadBehind.RemoteRef); } var parent = localBranchNode.CreateRootNode(pathToNode, (tree, parentPath) => new BranchPathNode(tree, parentPath));